# Malicious AGENTS.md hijacking coding agents via Downloads

- ID: forever-agents-md-hijack-2026
- Reported: 2026-11-04
- Researcher: Gal Weizman, Omer Samet
- Organization: Forever Security
- AI role: ai_agent_or_mcp_as_target (Agent / MCP as target)
- Confidence in AI involvement: high
- Research / borderline: false
- Last reviewed: 2026-11-04
- Entry page: https://openattacks.ai/attacks/forever-agents-md-hijack-2026/
- Entry JSON: https://openattacks.ai/api/attacks/forever-agents-md-hijack-2026.json
- Browse title: Malicious AGENTS.md hijacking coding agents via Downloads
- Editorial summary: Malicious AGENTS.md file dropped into ~/Downloads by website. When coding agent launches in Downloads directory, it reads and follows the malicious instructions. AGENTS.md variant edits ~/.codex/config.toml…
- Evidence class (catalog annotation): Not classified
- Source-stated target environments: Not specified
- Stage hunts and conditional defenses: https://openattacks.ai/api/defenses/forever-agents-md-hijack-2026.json

## Technique
Malicious AGENTS.md file dropped into ~/Downloads by website. When coding agent launches in Downloads directory, it reads and follows the malicious instructions. AGENTS.md variant edits ~/.codex/config.toml and runs npm install function-color (MALFEX downloader). CLAUDE.md variant steals OAuth tokens. Attack leverages agent instruction file priority and common workflow of developers launching agents in Downloads after downloading code samples or projects.

## Stack relevance (editorial)
Assessment: not\_assessed. No reviewed applicability annotation is available. Product mentions do not establish victim conditions.
A product mention alone is not a victim-side applicability mapping. Selection does not verify affected versions, permissions or compromise.

## Initial access
User visits malicious website that drops AGENTS.md into ~/Downloads

## AI tooling and models
- Coding agents (Codex, [Claude](https://claude.com/product/overview), others)
- Agent instruction files (AGENTS.md, CLAUDE.md)
- ~/.codex/config.toml

## Other tooling
- function-color npm package (MALFEX downloader)
- OAuth token theft

## Victims and sectors
Software developers using AI coding agents

## Target geography
- Multiple regions
Multiple regions reflects global developer population using coding agents

## Attribution
unknown

## Scale and metrics
Proof of concept demonstrating attack vector; actual deployment scale unknown

## Attack flow
Catalog reconstruction of the supplied source account. Unknowns and research caveats are preserved.
### drop: Malicious instruction file dropped to Downloads [access]
Website drops AGENTS.md or CLAUDE.md into ~/Downloads folder
Evidence: https://forever.security/blog/hijacking-ai-agents-via-downloads-folder/

### launch: Developer launches agent in Downloads [ai]
User starts coding agent in Downloads directory following common workflow for testing downloaded projects
Evidence: https://forever.security/blog/hijacking-ai-agents-via-downloads-folder/

### read: Agent reads malicious instruction file [ai]
Agent discovers and loads AGENTS.md or CLAUDE.md based on instruction file precedence
Evidence: https://forever.security/blog/hijacking-ai-agents-via-downloads-folder/

### execute: Malicious instructions executed [execution]
AGENTS.md variant edits ~/.codex/config.toml and runs npm install function-color; CLAUDE.md variant steals OAuth token
Evidence: https://forever.security/blog/hijacking-ai-agents-via-downloads-folder/

### impact: Malware installed or credentials stolen [impact]
function-color MALFEX downloader installed or OAuth tokens exfiltrated
Evidence: https://forever.security/blog/hijacking-ai-agents-via-downloads-folder/

Connections:
- drop -> launch
- launch -> read
- read -> execute
- execute -> impact

## Stage defense and hunting recommendations
Editorial recommendations, not validated coverage. Source-controlled query starters are drafts. Custom-schema examples require telemetry collection and field mapping; absence of a mapping means not assessed. MagicSword policy opportunities require managed Windows scope and enforcement.
### drop: Untrusted content enters an agent session
- Visibility: Application / agent audit records
- Query origin: catalog_authored; status: draft; log scope: custom_schema
- SIGMA query download: /api/detections/agent-input.sigma.yml
- KQL query download: /api/detections/agent-input.kql
- SPL query download: /api/detections/agent-input.spl
- Hunt hypothesis: An agent ingests external content or an untrusted session identifier before a tool action or configuration change outside the approved task.
- Required telemetry: Input provenance, source type and request/session identifier; Captured tool responses or retrieved content where collection is approved; Subsequent tool calls, configuration changes and approval decisions
- Investigate: Join the ingested input to later actions by session or request ID; preserve the original content as evidence.
- Investigate: Compare the resulting action with the approved task and baseline. Receiving suspicious text alone is not successful injection.
- Limitation: Requires application instrumentation and a custom field mapping. Input exposure does not prove that the model followed instructions, executed a tool or bypassed approval. Avoid collecting sensitive prompt bodies unless authorized.
- No direct MagicSword prevention claim is recorded for this stage.

### launch: No source-backed runtime hunt yet
- Visibility: Not established
- Query origin: catalog_authored; status: not_applicable; log scope: gap
- Hunt hypothesis: The supplied account does not establish a deployed victim-side behavior for this stage.
- Required telemetry: not assessed
- Investigate: Obtain a source-backed procedure and identify which party could observe it before drafting a detection.
- Limitation: Marketing claims, unknown steps and unconfirmed deployments are not detection coverage. No rule is generated for this stage.
- Qualification: Launching an agent in Downloads is common and is not independently a detection signal.
- No direct MagicSword prevention claim is recorded for this stage.

### read: Untrusted content enters an agent session
- Visibility: Application / agent audit records
- Query origin: catalog_authored; status: draft; log scope: custom_schema
- SIGMA query download: /api/detections/agent-input.sigma.yml
- KQL query download: /api/detections/agent-input.kql
- SPL query download: /api/detections/agent-input.spl
- Hunt hypothesis: An agent ingests external content or an untrusted session identifier before a tool action or configuration change outside the approved task.
- Required telemetry: Input provenance, source type and request/session identifier; Captured tool responses or retrieved content where collection is approved; Subsequent tool calls, configuration changes and approval decisions
- Investigate: Join the ingested input to later actions by session or request ID; preserve the original content as evidence.
- Investigate: Compare the resulting action with the approved task and baseline. Receiving suspicious text alone is not successful injection.
- Limitation: Requires application instrumentation and a custom field mapping. Input exposure does not prove that the model followed instructions, executed a tool or bypassed approval. Avoid collecting sensitive prompt bodies unless authorized.
- No direct MagicSword prevention claim is recorded for this stage.

### execute: Unexpected agent tool use
- Visibility: Defender-side logs where collected
- Query origin: catalog_authored; status: draft; log scope: custom_schema
- SIGMA query download: /api/detections/agent-tools.sigma.yml
- KQL query download: /api/detections/agent-tools.kql
- SPL query download: /api/detections/agent-tools.spl
- Hunt hypothesis: Untrusted content or a changed tool definition precedes a file read, command, or remote call outside the user's intended task.
- Required telemetry: Agent tool-call audit records with session / tool / destination; Tool-definition and approval changes; Endpoint process, file-access and network evidence where available
- Investigate: Join input provenance, tool descriptions and calls by session ID and compare the action to the approved task.
- Investigate: Inspect child processes and destinations; record whether execution was in-process, local, or through a remote SaaS connector.
- Limitation: Process logs cannot recover model intent. Remote connectors and in-process interpreters may produce no local child process. Prompt content alone is not a reliable signature.
- No direct MagicSword prevention claim is recorded for this stage.

### impact: Sensitive store access → credential use
- Visibility: Defender-side logs where collected
- Query origin: catalog_authored; status: draft; log scope: custom_schema
- SIGMA query download: /api/detections/credentials.sigma.yml
- KQL query download: /api/detections/credentials.kql
- SPL query download: /api/detections/credentials.spl
- Hunt hypothesis: An unexpected process or tool accesses credential stores and is followed by token use or outbound transfer inconsistent with the owner.
- Required telemetry: File-read / API access telemetry for relevant secret stores; Process identity and command lines; Identity, token and outbound-network audit logs
- Investigate: Identify the actor, process and exact store touched, then pivot to token use from new devices or infrastructure.
- Investigate: Correlate reads with egress and rotate affected credentials after confirming exposure.
- Limitation: Defender DeviceFileEvents is not a general file-read audit trail. Collect suitable object-access, EDR or application logs; legitimate developer tools also read secrets.
- No direct MagicSword prevention claim is recorded for this stage.


## MITRE ATLAS
Mappings are catalog annotations based on described behavior, not assignments or endorsements by MITRE.
- AML.T0051.001: Indirect — Malicious instruction file manipulates agent behavior by exploiting instruction file loading priority
  Technique: https://atlas.mitre.org/techniques/AML.T0051.001
  Evidence: https://forever.security/blog/hijacking-ai-agents-via-downloads-folder/
- AML.T0081: Modify AI Agent Configuration — AGENTS.md contains malicious instructions that modify agent configuration and install malware
  Technique: https://atlas.mitre.org/techniques/AML.T0081
  Evidence: https://forever.security/blog/hijacking-ai-agents-via-downloads-folder/
- AML.T0053: AI Agent Tool Invocation — Attack exfiltrates OAuth tokens via CLAUDE.md variant
  Technique: https://atlas.mitre.org/techniques/AML.T0053
  Evidence: https://forever.security/blog/hijacking-ai-agents-via-downloads-folder/
- AML.T0011.001: Malicious Package — Malicious instructions modify agent configuration files for persistence
  Technique: https://atlas.mitre.org/techniques/AML.T0011.001
  Evidence: https://forever.security/blog/hijacking-ai-agents-via-downloads-folder/

## Defensive notes
Review Downloads folder before launching agents; scan for unexpected .md instruction files; monitor ~/.codex/config.toml and other agent config modifications; detect npm install from unusual locations; restrict agent instruction file precedence; alert on OAuth token access from unexpected processes

## Sources
- https://forever.security/blog/hijacking-ai-agents-via-downloads-folder/ — Hijacking AI Agents via Downloads Folder

## Source notes
Relevant detection rules: - Monitor file creation in ~/Downloads directory for unexpected .md instruction files (AGENTS.md, CLAUDE.md) - Detect modifications to ~/.codex/config.toml and similar agent configuration files - Monitor npm install executions from non-standard directories (Downloads, temp folders) - Alert on OAuth token access from unexpected processes - Note: No direct Sigma rules for agent instruction file manipulation; requires custom file integrity monitoring for agent config directories and process monitoring for agent launches from untrusted paths. 
