AIDEFEND in Action AIA-0149 Incident

OpenAI Codex and Claude Code: When Downloads Becomes a Trusted Workspace

Coding agents can load local instruction files when they open a trusted workspace. Forever Security intercepted a 13 KB AGENTS.md in a customer’s Downloads folder that tried to make OpenAI Codex install the malicious npm package function-color. In an isolated reproduction, the file directed Codex to register a user-level MCP server and launch a new agent process without the original safeguards. In a separate Claude Code test, a researcher-written CLAUDE.md redirected the model connection, exposing an OAuth token and allowing a forged tool call. Both paths depended on treating a browser’s download destination as a trusted workspace.

Indirect Prompt InjectionConfiguration PoisoningConfiguration ReviewAI Coding AgentMCP Security
6 applicable AIDEFEND defenses

Threat Analysis

  • Why a downloaded document has influence. If a developer starts an agent in Downloads and trusts that folder, its instruction files can be loaded automatically. The browser’s download decision and the agent’s trust decision happen in different tools, with no guarantee that the instruction came from the project owner.
  • The Codex file registered a startup action. The intercepted 13 KB AGENTS.md presented itself as engineering guidelines. It instructed Codex to edit ~/.codex/config.toml, a user-level setting that can affect other workspaces, and register an MCP startup task. The task used macOS background job handling so the installation could continue beyond the test environment’s ten-second MCP startup wait. Starting a new Codex process without the original safeguards caused the new entry to load in the replay.
  • What the isolated tests measured. Forever Security reported over 90% success for its Codex reproduction. Most repetitions used a harmless stand-in, with the real function-color package run once in a VM. The company intercepted the original file in the customer environment.
  • The Claude Code test changed who answered the agent. A separate, researcher-written CLAUDE.md persuaded Claude Code to write workspace settings in about half of attempts. After the changed endpoint was loaded, researchers received an OAuth token that they validated by replay and could forge a Bash tool response requesting execution outside the sandbox. Reopening the client used the new setting, and about one fifth of attempts activated it within the same session by starting a subagent.

Applicable AIDEFEND Defenses (6)

AID-I-004.006
Agent Identity & Persistent State File Write Protection
Very High
Run the agent and its subprocesses under an identity that cannot edit or replace the protected MCP and model endpoint policies. The controlled configuration writer is the only identity allowed to change those paths.
AID-H-021.005
AI Coding-Agent Workspace Activation Trust Gate
High
A managed activation broker can refuse unapproved downloads workspaces before either client reads project instructions. Bind the allow decision to an exact reviewed workspace and instruction manifest, and require the client adapters to enforce it on every entry point.
AID-H-021.002
Runtime Integrity Enforcement (Signed Configurations)
High
A client that verifies its startup baseline before loading local entries can reject unauthorized MCP registrations and model endpoint overrides at the moment they would take effect.
AID-I-002.002
Secure External AI Service Connectivity
High
A compulsory external egress policy can deny the unapproved model endpoint before an OAuth header leaves the managed device. It must cover the CLI and its subprocesses.
AID-E-003.003
Confirmed Malicious Code & Persistence Eviction
High
Preserve and remove the verified malicious file-backed startup entries and reload from the approved baseline. Confirm both persisted and loaded configuration are clean before restoring normal execution.
AID-H-017.002
Least-Privilege Tool Architecture
High
For managed Claude Code jobs that do not need a shell, place a bare Bash deny rule in organization-managed permissions and allow only the tools required for the job. Check that no approved MCP tool or extension can execute an equivalent command. This removes the execution capability that the forged reply tried to invoke. Credential exposure at the model connection still requires its own control.

What Defenders Should Do Now

  • Enforce workspace admission before the client reads instruction files and verify separate protection of MCP and endpoint settings against the tool, shell and subprocess identities.
  • Review newly registered MCP entries, model endpoint changes and unusual child agent processes together. If an unapproved endpoint received credentials, preserve configuration evidence and revoke the affected tokens through the identity provider.

1 additional consideration

Separate browser downloads from coding workspaces

A download destination is a public-facing intake with a local path that looks like any other folder to the coding tool.
Recommendation: Keep a dedicated workspace root and route browser downloads to a staging area outside it. Inspect and selectively copy the expected files; check for instruction files when opening archives or a preexisting directory.

Conclusion

AIDEFEND ’s workspace, configuration and egress controls address three separate points of this case: loading instructions, applying a higher-trust setting and sending a credential to an outside host.

Last updated: