Malicious Markdown Files Can Redirect AI Coding Agents and Expose Credentials

| 2 Min Read
Tests show how trusted instruction files can push Codex and Claude Code to alter settings, run commands, or expose tokens.

AI coding agents can turn a plain Markdown file into a route to sensitive settings and credentials. Forever Security says it blocked an attempted attack on a customer’s computer and reproduced related techniques against OpenAI Codex and Anthropic Claude Code.

The incident involved an AGENTS.md file in the customer’s Downloads folder. It told Codex to install a malicious npm package named function-color. The installation was stopped before the malware ran. Researchers couldn’t establish how the file arrived, but demonstrated that a malicious website could prompt a similar download without asking for separate approval.

The risk comes from a feature meant to guide coding work: Codex reads AGENTS.md files, while Claude Code supports CLAUDE.md. When an agent works in a directory containing one of these files, it can interpret its contents as instructions. The attack therefore depends on the agent processing the file in the affected directory; Codex must also treat that directory as trusted, Forever Security said.

Instructions can reach beyond a project

Using the recovered file, researchers found that Codex could be directed to change its machine-wide MCP server configuration and start another session with approval and sandbox restrictions bypassed. Codex followed the instructions in more than 90% of tests. Most tests used a harmless substitute for the malware.

The change could persist across directories: once registered in the machine-wide configuration, the malicious server could load in later sessions even after a developer moved elsewhere. A separate Claude Code demonstration showed a malicious CLAUDE.md file redirecting API traffic to a researcher-controlled server. That could expose authentication tokens and let the server return commands for the agent to run. The configuration change succeeded in about half the tests.

Researchers also replayed a captured OAuth token against the legitimate API, demonstrating a path to account compromise. The files themselves contained no executable code. The mechanism was the agent treating their text as valid instructions and acting with permissions it already had.

Sakshi Grover, IDC’s senior research manager for cybersecurity products and services for Asia/Pacific, described the findings as a credible early warning, not proof of widespread exploitation. She said the reported success rates differed between agents and hadn’t been independently validated.

The boundary between instructions and permissions

For Akshat Tyagi, associate practice leader at HFS Research, the issue reaches beyond a Downloads folder. Coding agents are designed to follow project guidance, yet may also have access to sensitive configuration and the ability to execute commands. “The deeper issue is that these tools treat following an instruction and granting a privilege as the same act,” he said.

Tyagi called for separating those functions so that a project file can’t change an agent’s security settings without independent human approval. Grover recommended checking where instruction files come from and asking users before loading files from untrusted sources.

The same pattern could appear wherever an agent reads content, including cloned repositories, shared drives, and package contents. Grover said the wider concern is “agents ingesting untrusted content and holding live credentials,” rather than the Downloads folder itself.

Controls for teams using coding agents

Omdia’s Cybersecurity Decision-Maker survey found that 40% of respondents were only somewhat confident or not confident in their organization’s ability to secure AI agents, according to Jonathan Ong, the firm’s senior analyst for managed security services. He recommended human oversight for suspicious behavior and limits on settings that let agents bypass security controls.

“Disabling flags such as ‘–dangerously-bypass-approvals-and-sandbox’ would limit the agent’s authorization to run high-risk actions,” Ong said.

Amit Kumar Jena, development manager for AI at Kanerika, advised treating AGENTS.md, CLAUDE.md, and related configuration directories like source code, with named owners reviewing changes. He also recommended keeping sandboxes enabled, limiting network access, and routing software installs through internal package registries or scanning proxies.

For developers whose machines hold production credentials, Jena suggested isolated development environments and enterprise-controlled gateways that use shorter-lived authentication tokens. His guiding distinction is simple: “An instruction file can change what the agent tries. It must never change what the agent is allowed to do.”

Source: David Rodriguez · www.csoonline.com

Comments

Please sign in to comment.