Nation-State Hackers Are Targeting Your AI Agent Keys
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.
TL;DR
- Research from April 2026 documented trojanized npm packages carrying OtterCookie, designed to target developer directories such as .cursor, .claude, and .gemini for API keys, transcripts, and configuration data.
- A separate November 2025 report documented an earlier wave of the DPRK-linked Contagious Interview campaign that delivered malicious npm dependencies through deceptive interview tasks.
- Analysis identified four operational modules in the examined samples: remote shell access, browser and wallet credential collection, home-directory file exfiltration, and clipboard monitoring.
- A compromised model API key allows unauthorized model calls under that key but does not grant separately authenticated local tool access or desktop permissions, and local runtime guards do not stop hostile malware.
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.
Open full-size image (opens in new tab)
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:
- Remote access (RAT): Full shell access to the victim's machine
- Credential theft: Browser passwords, digital currency wallets (Chrome, Brave, Edge)
- File exfiltration: Sweeps the home directory for
.env,.pem,.key,.json,.csv,.doc,.pdf,.xlsx - 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
postinstallscripts) - Use
npm auditand 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.
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:
Copy-ready prompt
Paste the exact block into your coding agent.
No article chrome, no footnotes, no formatting drift.
This prompt and every other one we publish live in the free prompt library.
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.
Related: LLM API Router Supply Chain Is Compromised | Prompt Injection Guide for Business
Sources: cyberandramen.net analysis | The Hacker News | arXiv 2604.08407
FAQ
What targets were identified in the OtterCookie analysis?
The April 2026 analysis documented trojanized npm packages targeting developer directories to exfiltrate provider API keys, tool configurations, and local files.
How was the earlier Contagious Interview campaign related?
A separate November 2025 report documented an earlier wave of the DPRK-linked Contagious Interview campaign that distributed malicious npm dependencies through deceptive interview assignments.
Can local runtime guards or budgets stop malicious npm packages?
No. Local runtime guards and budgets manage cooperative agent calls, but local malware executing on a machine can read accessible files and bypass co-located checks.
Get the Local AI Field Kit
Four copy-ready tools now, then one evidence-backed Local AI Lab Note on Friday when there is something worth sharing.
Try the free agent run check firstGet the requested artifact now, then at most one evidence-backed Local AI Lab Note on Friday when there is something worth sharing. One-click unsubscribe. No sponsored placements. Privacy.
Written by
Patrick Hughes
I build BMD and publish measured AI runs, failure reports, and reusable checks. Nashville, Tennessee.
More writing
- 6 min
PostHog Rebuilt Their AI Architecture Twice. Here Are the 5 Rules They Learned.
PostHog ships to thousands of daily agent users. They rebuilt their AI architecture twice before getting it right. Here are the 5 rules they distilled, reframed for builders shipping agent features.
- 6 min
Study Found 9 Malicious Routers in 428 Tested Proxies
An April 2026 study examined 428 LLM routers and found malicious injection. Proxies can inspect sent requests even when transport encryption protects the link.
- 5 min
57-71% of AI agents leak data between users. Here's what to do.
A June 2026 Mem0 survey of 8 major agent harnesses found that over half of them leak memory across users. Here is why keyword retrieval is a security risk and how to fix it.
- 5 min
57-71% of AI Agents Leak Data Between Users. Here's the Fix.
A 2026 Mem0 survey found 57-71% cross-user memory contamination across major agent frameworks. Here is why it happens and how to stop it.
- 5 min
Securing Your AI Agents: Essential Practices for On-Device Automation
The AI world is buzzing, but recent events highlight the critical need for secure and efficient AI agents. Discover practical engineering steps for building reliable automation directly on your hardware.