---
title: "Nation-State Hackers Are Targeting Your AI Agent Keys"
excerpt: "North Korean threat actors are targeting AI coding tools. Trojanized npm packages hunt for .cursor, .claude, .gemini, and .windsurf directories to steal API keys and source code."
author: "Patrick Hughes"
published_at: 2026-04-14T14:03:21.307+00:00
read_time_min: 5
tags: ["ai-agents", "security", "supply-chain", "npm"]
canonical: https://bmdpat.com/blog/ottercookie-ai-tool-supply-chain-attack-2026
---

North Korean threat actors are targeting AI coding tools. April 2026 analysis documented this activity.

A trojanized npm campaign called OtterCookie is explicitly scanning for `.cursor`, `.claude`, `.gemini`, `.windsurf`, and `.pearai` directories on developer machines. The goal: steal your API keys, conversations with LLMs, and source code.

The April 4, 2026 analysis documented active malware with nation-state backing.

![Local Agent Safeguards: Inspect Past Spend, Record Incurred Usage, Cooperative Timeouts.](/blog-assets/ottercookie-ai-tool-supply-chain-attack-2026.png)

## What happened

In research published November 26, 2025, Socket reported that the DPRK-linked Contagious Interview campaign published at least 197 additional malicious npm packages with over 31,000 downloads. Separately, an April 4, 2026 primary analysis by Cyber and Ramen identified samples targeting AI coding tools, using package names designed to look legitimate such as `gemini-ai-checker`, `express-flowlimit`, `chai-extensions-extras`, and others mimicking popular libraries.

The delivery mechanism: fake job interviews and coding test assignments. A developer gets a "take-home project" that requires `npm install`. One of the dependencies is backdoored.

Once installed, OtterCookie runs four independent modules:

1. **Remote access (RAT):** Full shell access to the victim's machine
2. **Credential theft:** Browser passwords, digital currency wallets (Chrome, Brave, Edge)
3. **File exfiltration:** Sweeps the home directory for `.env`, `.pem`, `.key`, `.json`, `.csv`, `.doc`, `.pdf`, `.xlsx`
4. **Clipboard monitoring:** Captures anything copied, including API keys and secrets

## Why AI tools are the new target

The OtterCookie variant evaluated in the April 4, 2026 analysis specifically targeted AI coding tool directories. These directories contain:

- **API keys** for Claude, OpenAI, Gemini, and other providers
- **Conversation history** with LLMs (which often contains proprietary code, architecture decisions, and business logic)
- **Configuration files** with endpoint URLs, model preferences, and authentication tokens
- **MCP server configs** that may reference internal infrastructure

A stolen Claude API key permits an attacker to make calls within that key's API permissions and generate content against your account quota. A stolen model API key alone does not grant access to separately authenticated local MCP tools or desktop environments, though separate theft of local tool configs or host credentials can create distinct access risks.







## How to protect yourself

### 1. Treat AI tool directories like .ssh

Your `.claude/`, `.cursor/`, and `.gemini/` directories contain secrets. Treat them with the same security posture as `.ssh/`.

- Add them to your `.gitignore` (most are already, but verify)
- Monitor file access with your OS audit tools
- Rotate API keys regularly
- Never store keys in plaintext config files when your provider offers environment variables

### 2. Verify npm packages before installing

The OtterCookie packages look legitimate. `gemini-ai-checker` sounds like it could be real. Before you `npm install` anything from a job interview take-home:

- Check the publisher's npm profile
- Look at the package age and download count
- Read the source (especially `postinstall` scripts)
- Use `npm audit` and tools like Socket.dev

### 3. Run agents with budget limits

Guards in your process do not bound an attacker who runs your stolen key from their own machine. Rotate the key for that. Process guards are not a sandbox and cannot contain arbitrary malicious code, because code executing in the same process can bypass or modify them. What guards can bound is cooperating, instrumented call paths on your machine, helping stop an agent loop or runaway tool chain before it issues further recorded requests.

```python
from agentguard import BudgetGuard, TimeoutGuard

budget = BudgetGuard(max_cost_usd=5.00)

with TimeoutGuard(max_seconds=300) as clock:
    for step in agent.plan(task):
        budget.check()
        clock.check()
        result = step.run()
        budget.consume(calls=1, cost_usd=result.cost_usd)
```

This does not prevent key theft, router malware, or hostile code in the same process. It bounds recorded calls within your local loop: budget checks inspect past recorded usage before each step, consume records usage after the call and raises if the limit was reached, and cooperative timeouts check duration without interrupting blocking tools. Test your actual call path with local guards before connecting live credentials or broad file access.

### 4. Audit your agent pipeline end to end

Know every dependency, every API hop, and every tool your agent can access. If you cannot draw the full chain from prompt to action, you have blind spots an attacker can exploit.

## The bigger picture

Supply chain attacks target AI tools and dependencies directly: OtterCookie scanning AI tool directories, research showing 9 out of 428 tested API routers injecting malicious code, and attacks hitting toolchain packages.

The AI agent supply chain is under active attack from multiple directions. The tools developers trust most (npm packages, API routers, coding assistants) are the exact vectors being exploited.

This is not going to get better on its own. Secure your keys. Verify your packages. Set your limits.

---

### Accompanying prompt
**What the prompt does:** Inspects supplied agent call paths to insert local budget and timeout boundaries without executing code.
Copy/paste this prompt:
```text
Role:
AI Security Reviewer

Context:
You are inspecting local agent orchestration code and tool calling workflows for missing spend and timeout boundaries.

Task:
1. Inspect supplied agent call paths for unbounded loops and unmonitored external calls.
2. Place BudgetGuard and TimeoutGuard checks around step loops, inspecting recorded usage before calls and consuming incurred usage after calls.
3. Test guard limits and verify handling when unpriced models return zero estimated cost.

Output:
A code review summarizing inserted guard checkpoints, exception handling, and unknown model fallback logic.

Constraints:
Use supplied files only. No execution, credentials, spending or network.
```
Copy the block above.

**AgentGuard** is an open-source Python SDK for AI agent runtime safety. Budget limits and loop detection. Zero dependencies. Runs locally.

[Get started with AgentGuard](https://bmdpat.com/tools/agentguard)

*Related: [LLM API Router Supply Chain Is Compromised](https://bmdpat.com/blog/llm-api-router-supply-chain-compromised-2026) | [Prompt Injection Guide for Business](https://bmdpat.com/blog/prompt-injection-ai-agents-business-guide-2026)*

*Sources: [cyberandramen.net analysis](https://cyberandramen.net/2026/04/04/ottercookie-expands-targeting-to-ai-coding-tools-analysis-of-a-trojanized-npm-campaign/) | [The Hacker News](https://thehackernews.com/2025/11/north-korean-hackers-deploy-197-npm.html) | [arXiv 2604.08407](https://arxiv.org/abs/2604.08407)*

---

---

Get the local AI lab notes (benchmark rows, VRAM fit, quant choices, what runs on consumer GPUs), M-F only when there is something worth sending: https://bmdpat.com/newsletter?utm_source=blog_md&utm_medium=aeo&utm_campaign=ottercookie-ai-tool-supply-chain-attack-2026
