NVIDIA Red Team — Indirect AGENTS.md Injection via Malicious Dependencies

AI relevance: AI coding agents like OpenAI Codex treat AGENTS.md files as trusted project-level instructions, creating a new supply-chain attack surface where a malicious dependency can hijack agent behavior by writing instructions into those files during package installation.

What happened

  • NVIDIA's AI Red Team demonstrated a simulated attack where a seemingly benign Go library (github.com/cursorwiz/echo) wrote a crafted AGENTS.md file during go mod tidy setup.
  • The injected AGENTS.md exploited instruction precedence — the agent treated the malicious file as legitimate project context, overriding the developer's actual intent.
  • The attack chain: dependency installs → AGENTS.md is created or modified → agent ingests the file as trusted instructions → agent behavior is silently redirected.
  • In the demo, a developer asked Codex to change a greeting string; the injected instructions hijacked the agent's summarization logic and output behavior.
  • This is indirect prompt injection through the dependency supply chain — distinct from web-content-based IPI because the injection persists on disk and affects every agent session on that project.
  • Even when the agent has no internet access, the poisoned dependency (already downloaded) still carries the malicious payload into the agent's context.
  • The research highlights a fundamental trust-model gap: AGENTS.md files are designed to be authoritative, but their placement within the project tree means any build-time artifact can create or modify them.

Why it matters

  • Every agentic coding tool that reads AGENTS.md (Codex, Cursor, Claude Code, and others adopting the convention) inherits this trust assumption.
  • Unlike traditional supply-chain attacks that need code execution, this vector works by influencing the agent's reasoning — the agent voluntarily follows the attacker's instructions because they appear as project configuration.
  • The attack is persistent: once the dependency is in go.sum or package.json, every developer and CI agent running the project is exposed.
  • Current dependency scanning tools (SAST, SCA) look for malicious code patterns, not for side effects like file creation during package installation.

What to do

  • Treat AGENTS.md files as security-sensitive configuration — include them in code review and CI checks, similar to .env or secrets files.
  • Pin dependency versions and review lock-file diffs for unexpected new packages, especially in setup scripts.
  • Consider agent-side guardrails: require explicit user confirmation before following instructions from AGENTS.md files created by untrusted dependencies.
  • Monitor for post-install hooks in package managers (postinstall in npm, build scripts in Go) that write project-level configuration files.

Sources: