Skip to content

AI coding agents can be hijacked by a malicious AGENTS.md file in the Downloads folder

A malicious AGENTS.md file placed in a user's ~/Downloads folder can hijack AI coding agents, causing rogue npm installations, unauthorised command execution or OAuth token leakage. The attack exploits default browser download behaviour and requires the agent to be started in the same folder.

Close-up of colorful text on a computer screen, showcasing cybersecurity concepts.

Many developers run AI‑powered coding assistants from the folder where they keep downloaded files, often the ~/Downloads directory. That convenience creates a hidden attack surface: a specially crafted AGENTS.md file placed there can silently take control of the assistant, install rogue npm packages, run arbitrary commands, or expose authorisation tokens.

What is an AGENTS.md file?

An AGENTS.md file is a plain‑text markdown document that contains project‑specific instructions for AI coding agents. When an agent starts, it scans the current working directory for recognised instruction files, such as AGENTS.md, CLAUDE.md or similar, and automatically loads any it finds. The content of these files directly influences the agent’s behaviour.

How the hijack works

  1. File drop, A malicious webpage can cause a browser to download an AGENTS.md file without prompting the user. Chrome, Edge and Firefox save downloads to ~/Downloads by default; Brave asks for confirmation.
  2. Agent launch, The attacker’s success hinges on the user launching the AI coding agent from the same directory. The agent then reads the malicious AGENTS.md file and follows its instructions.
  3. Malicious payload, The file can contain commands that the agent executes with the same privileges it already has. Researchers demonstrated this by:
  4. Installing a rogue npm package that could later be used to exfiltrate data.
  5. Executing a harmless payload (opening the calculator) in 90 % of trials against OpenAI Codex.
  6. Redirecting Claude Code’s API traffic, exposing the OAuth token and achieving code execution in roughly half of the tests.

The researchers could not definitively prove how the file reached the victim’s ~/Downloads folder, but they confirmed that a silent drop from a malicious page is a plausible vector.

Close-up of HTML code displayed on a MacBook Pro screen, showcasing modern web development.

Photo by Digital Buggu on Pexels

Scope and impact

Internal statistics show that hundreds of customers run AI agents from their ~/Downloads folders. Claude Code alone launched more than 1,300 sessions from that location. When the malicious file is present, the risk is not theoretical, proof‑of‑concept attacks succeeded in the vast majority of attempts.

What you should do today

  • Never use ~/Downloads as the working directory for an AI coding agent. Start the agent from the project’s root folder where source code lives.
  • Inspect any AGENTS.md, CLAUDE.md or similar files before allowing an agent to process them. Look for unexpected commands or package installations.
  • Keep approval prompts and sandbox protections enabled in the agent’s settings. These act as a second line of defence if the agent tries to run something it does not normally request permission for.
  • Test untrusted code in an isolated environment, for example, a disposable virtual machine or container, before executing it on your primary workstation.

Following these steps reduces the chance that a stray file in ~/Downloads can compromise your development workflow.

Terms used in this article

  • AGENTS.md, A markdown file that provides instructions to AI coding agents about how to operate on a project.
  • npm, The package manager for the Node.js JavaScript runtime; it installs libraries that code can import.
  • OAuth token, A credential that authorises an application to act on a user’s behalf when accessing a service.
  • Sandbox, An isolated execution environment that limits what a programme can do to the host system.

This guidance reflects the current understanding of the attack as of November 2026. The situation may evolve, and organisations should stay alert to new developments.