Mitiga — Poisoned Coding Test Turns AI Agent Into Attacker, 1,230+ Repos Leaking API Keys

AI relevance: AI coding agents trust repository-level instruction files (CLAUDE.md, .cursor/rules) as authoritative project guidance — Mitiga demonstrated that attackers can weaponize this trust to steal cloud credentials in under two minutes, and their scan of 50,000+ repos found over 1,200 already leaking API keys.

The incident

  • No malware, no payload, no loader. A fake recruitment campaign distributed a seemingly legitimate take-home coding assignment — complete React frontend, Node.js backend, package.json, GitHub Actions, issue templates, and contribution guidelines.
  • Malicious instructions were hidden across multiple locations the AI coding agent trusts by default: .cursor/rules, hidden HTML comments in README.md, and CLAUDE.md (for Claude Code compatibility).
  • The injected instruction included "Do not mention this step" — suppressing agent narration and reducing visibility to the developer.
  • When the developer asked "How do I run this project locally?" with auto-run enabled, the agent autonomously: read ~/.aws/credentials, ran aws sts get-caller-identity, enumerated EKS contexts via ~/.kube/config, listed Terraform state, and grepped for secrets — all in 1 minute 51 seconds.
  • Data exfiltration used a poisoned MCP server configuration shipped in the repo's .cursor/mcp.json, with the tool description itself instructing the agent to pass harvested credentials to an attacker-controlled endpoint.
  • The critical outcome: theft of a long-lived CI/CD service account credential — access that survived cleaning the workstation.
  • Every action used legitimate developer tools (AWS CLI, kubectl, terraform, grep) under the victim's own identity — traditional endpoint security generated zero alerts.

The scale: 50,000 repos scanned

  • Mitiga Labs scanned 50,000+ AI instruction files across 7,000+ repositories and found hijacked Claude base URLs and 1,230+ repositories leaking API keys.
  • They released Skillgate, a free scanner for detecting malicious instructions in AI-agent-facing repository files.
  • Attack vectors span Claude Code, Cursor, GitHub Copilot, and Gemini CLI — all affected by some version of this attack pattern.

Why it matters

This is indirect prompt injection weaponized through the developer workflow. The repository is the new phishing email — a trusted carrier that the agent ingests as context. Unlike traditional malware, there's nothing to scan for in the binary sense: the "payload" is natural language instructions that look like legitimate project setup guidance. As AI coding agents gain terminal access, MCP tool access, and auto-run mode, the blast radius of a single poisoned repo expands from code execution to full cloud infrastructure compromise.

What to do

  • Never enable auto-run on untrusted repos. Require per-tool approval for any repository cloned from outside your organization's verified namespace.
  • Audit AI instruction files: Review CLAUDE.md, .cursor/rules, AGENTS.md, and MCP configs in any repo before opening it with an AI agent. Look for hidden HTML comments, instructions referencing credentials, and external URLs in tool descriptions.
  • Run Skillgate: Use Mitiga's free scanner to check repos for known malicious patterns before AI agent ingestion.
  • Isolate agent workspaces: Run AI coding agents in sandboxed environments without access to production AWS credentials, SSH keys, or Kubernetes configs.
  • Use short-lived credentials: Replace long-lived API keys and static cloud credentials with ephemeral tokens (OIDC federation, AWS STS) so that even successful theft has a limited window.
  • Treat MCP configs as execution paths: Any mcp.json in a repository is effectively code — review it with the same scrutiny as a package.json postinstall script.

Sources