Malicious AGENTS.md hijacking coding agents via Downloads
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…
What happened
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.
How it happened
Read the flow as text & sources
A catalog reconstruction of the supplied source account. Unknown steps remain explicit; an edge describes the reported relationship between steps.
- 01 · Malicious instruction file dropped to Downloads
Website drops AGENTS.md or CLAUDE.md into ~/Downloads folder
Hunt: An agent ingests external content or an untrusted session identifier before a tool action or configuration change outside the approved task.
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.
Source for step 1 - 02 · Developer launches agent in Downloads
User starts coding agent in Downloads directory following common workflow for testing downloaded projects
Source for step 2 - 03 · Agent reads malicious instruction file
Agent discovers and loads AGENTS.md or CLAUDE.md based on instruction file precedence
Hunt: An agent ingests external content or an untrusted session identifier before a tool action or configuration change outside the approved task.
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.
Source for step 3 - 04 · Malicious instructions executed
AGENTS.md variant edits ~/.codex/config.toml and runs npm install function-color; CLAUDE.md variant steals OAuth token
Hunt: Untrusted content or a changed tool definition precedes a file read, command, or remote call outside the user's intended task.
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.
Source for step 4 - 05 · Malware installed or credentials stolen
function-color MALFEX downloader installed or OAuth tokens exfiltrated
Hunt: An unexpected process or tool accesses credential stores and is followed by token use or outbound transfer inconsistent with the owner.
Defender DeviceFileEvents is not a general file-read audit trail. Collect suitable object-access, EDR or application logs; legitimate developer tools also read secrets.
Source for step 5
Why it matters
Reported entry point: User visits malicious website that drops AGENTS.md into ~/Downloads. Reported impact: function-color MALFEX downloader installed or OAuth tokens exfiltrated; reported targets include Software developers using AI coding agents; applicability to your setup has not been assessed, so verify affected versions, permissions, and configuration in the original report.
What you can do
Protection & prevention
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
Catalog defensive guidance based on the reported behavior. Confirm scope and current mitigations in the original source.
Detection queries
Draft query starters grouped by the attack stages where they apply.
Start with the logs you collect. Each hunt identifies its required visibility, field mapping and limits. Queries are catalog-authored drafts using reusable behavior profiles; test with known activity and your normal baseline before alerting.
01Malicious instruction file dropped to DownloadsUntrusted content enters an agent sessionCustom schema · Draft
Website drops AGENTS.md or CLAUDE.md into ~/Downloads folder
What to look for
An agent ingests external content or an untrusted session identifier before a tool action or configuration change outside the approved task.
Visibility: Application / agent audit records
Required logs
- 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
Coverage limit. 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.
Custom-schema candidate for input exposure only. Map agent.input.ingest and agent.session.resume to your application request and session logs. CorrelationId must link subsequent actions. EventType values are proposed normalization names, not native vendor events.
Sigma
title: Hunt - Untrusted content enters an agent session
id: 2d89d7ae-9d44-4dc6-a95b-f9c8de7b8352
status: experimental
description: An agent ingests external content or an untrusted session
identifier before a tool action or configuration change outside the approved
task.
author: MagicSword OpenAttacks catalog
date: 2026-11-04
falsepositives:
- Authorized activity matching this broad hunt; baseline and investigate
before alerting.
level: low
logsource:
category: application
product: openattacks_audit
definition: Custom normalized audit schema; map EventType, Actor, Asset, Action,
Target and CorrelationId from the required source logs first.
detection:
selection:
EventType:
- agent.input.ingest
- agent.session.resume
condition: selection
KQL
// SCHEMA TEMPLATE: create/map this custom table before use; not a built-in Sentinel table.
// OpenAttacksAudit_CL: TimeGenerated(datetime), EventType/Actor/Asset/Action/Target/CorrelationId(string).
// Selects candidates only. Apply the stage hypothesis and correlation steps before alerting.
OpenAttacksAudit_CL
| where TimeGenerated > ago(7d)
| where EventType in ("agent.input.ingest", "agent.session.resume")
| project TimeGenerated, EventType, Actor, Asset, Action, Target, CorrelationId
| order by TimeGenerated descSPL
sourcetype="openattacks:audit"
EventType IN ("agent.input.ingest", "agent.session.resume")
| table _time EventType Actor Asset Action Target CorrelationId
| sort - _timeInvestigation steps
- Join the ingested input to later actions by session or request ID; preserve the original content as evidence.
- Compare the resulting action with the approved task and baseline. Receiving suspicious text alone is not successful injection.
03Agent reads malicious instruction fileUntrusted content enters an agent sessionCustom schema · Draft
Agent discovers and loads AGENTS.md or CLAUDE.md based on instruction file precedence
What to look for
An agent ingests external content or an untrusted session identifier before a tool action or configuration change outside the approved task.
Visibility: Application / agent audit records
Required logs
- 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
Coverage limit. 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.
Custom-schema candidate for input exposure only. Map agent.input.ingest and agent.session.resume to your application request and session logs. CorrelationId must link subsequent actions. EventType values are proposed normalization names, not native vendor events.
Sigma
title: Hunt - Untrusted content enters an agent session
id: 2d89d7ae-9d44-4dc6-a95b-f9c8de7b8352
status: experimental
description: An agent ingests external content or an untrusted session
identifier before a tool action or configuration change outside the approved
task.
author: MagicSword OpenAttacks catalog
date: 2026-11-04
falsepositives:
- Authorized activity matching this broad hunt; baseline and investigate
before alerting.
level: low
logsource:
category: application
product: openattacks_audit
definition: Custom normalized audit schema; map EventType, Actor, Asset, Action,
Target and CorrelationId from the required source logs first.
detection:
selection:
EventType:
- agent.input.ingest
- agent.session.resume
condition: selection
KQL
// SCHEMA TEMPLATE: create/map this custom table before use; not a built-in Sentinel table.
// OpenAttacksAudit_CL: TimeGenerated(datetime), EventType/Actor/Asset/Action/Target/CorrelationId(string).
// Selects candidates only. Apply the stage hypothesis and correlation steps before alerting.
OpenAttacksAudit_CL
| where TimeGenerated > ago(7d)
| where EventType in ("agent.input.ingest", "agent.session.resume")
| project TimeGenerated, EventType, Actor, Asset, Action, Target, CorrelationId
| order by TimeGenerated descSPL
sourcetype="openattacks:audit"
EventType IN ("agent.input.ingest", "agent.session.resume")
| table _time EventType Actor Asset Action Target CorrelationId
| sort - _timeInvestigation steps
- Join the ingested input to later actions by session or request ID; preserve the original content as evidence.
- Compare the resulting action with the approved task and baseline. Receiving suspicious text alone is not successful injection.
04Malicious instructions executedUnexpected agent tool useCustom schema · Draft
AGENTS.md variant edits ~/.codex/config.toml and runs npm install function-color; CLAUDE.md variant steals OAuth token
What to look for
Untrusted content or a changed tool definition precedes a file read, command, or remote call outside the user's intended task.
Visibility: Defender-side logs where collected
Required logs
- Agent tool-call audit records with session / tool / destination
- Tool-definition and approval changes
- Endpoint process, file-access and network evidence where available
Coverage limit. 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.
Custom-schema candidates, not out-of-box detectors. Map your application / cloud / platform logs to EventType, Actor, Asset, Action, Target and CorrelationId. KQL uses a custom OpenAttacksAudit_CL table; SPL uses openattacks:audit. EventType values are proposed normalization names, not native vendor event names. Correlation and environment-specific alert logic remain to be built.
Sigma
title: Hunt - Unexpected agent tool use
id: c709e384-0e11-479e-ab4d-3a06e2431e4b
status: experimental
description: Untrusted content or a changed tool definition precedes a file
read, command, or remote call outside the user's intended task.
author: MagicSword OpenAttacks catalog
date: 2026-10-23
falsepositives:
- Authorized activity matching this broad hunt; baseline and investigate
before alerting.
level: low
logsource:
category: application
product: openattacks_audit
definition: Custom normalized audit schema; map EventType, Actor, Asset, Action,
Target and CorrelationId from the required source logs first.
detection:
selection:
EventType:
- agent.tool.call
- agent.tool.definition.change
condition: selection
KQL
// SCHEMA TEMPLATE: create/map this custom table before use; not a built-in Sentinel table.
// OpenAttacksAudit_CL: TimeGenerated(datetime), EventType/Actor/Asset/Action/Target/CorrelationId(string).
// Selects candidates only. Apply the stage hypothesis and correlation steps before alerting.
OpenAttacksAudit_CL
| where TimeGenerated > ago(7d)
| where EventType in ("agent.tool.call", "agent.tool.definition.change")
| project TimeGenerated, EventType, Actor, Asset, Action, Target, CorrelationId
| order by TimeGenerated descSPL
sourcetype="openattacks:audit"
EventType IN ("agent.tool.call", "agent.tool.definition.change")
| table _time EventType Actor Asset Action Target CorrelationId
| sort - _timeInvestigation steps
- Join input provenance, tool descriptions and calls by session ID and compare the action to the approved task.
- Inspect child processes and destinations; record whether execution was in-process, local, or through a remote SaaS connector.
05Malware installed or credentials stolenSensitive store access → credential useCustom schema · Draft
function-color MALFEX downloader installed or OAuth tokens exfiltrated
What to look for
An unexpected process or tool accesses credential stores and is followed by token use or outbound transfer inconsistent with the owner.
Visibility: Defender-side logs where collected
Required logs
- File-read / API access telemetry for relevant secret stores
- Process identity and command lines
- Identity, token and outbound-network audit logs
Coverage limit. Defender DeviceFileEvents is not a general file-read audit trail. Collect suitable object-access, EDR or application logs; legitimate developer tools also read secrets.
Custom-schema candidates, not out-of-box detectors. Map your application / cloud / platform logs to EventType, Actor, Asset, Action, Target and CorrelationId. KQL uses a custom OpenAttacksAudit_CL table; SPL uses openattacks:audit. EventType values are proposed normalization names, not native vendor event names. Correlation and environment-specific alert logic remain to be built.
Sigma
title: Hunt - Sensitive store access → credential use
id: 46c46c62-2d83-4198-a8bf-d6637094527b
status: experimental
description: An unexpected process or tool accesses credential stores and is
followed by token use or outbound transfer inconsistent with the owner.
author: MagicSword OpenAttacks catalog
date: 2026-10-23
falsepositives:
- Authorized activity matching this broad hunt; baseline and investigate
before alerting.
level: low
logsource:
category: application
product: openattacks_audit
definition: Custom normalized audit schema; map EventType, Actor, Asset, Action,
Target and CorrelationId from the required source logs first.
detection:
selection:
EventType:
- secret.read
- credential.store.read
condition: selection
KQL
// SCHEMA TEMPLATE: create/map this custom table before use; not a built-in Sentinel table.
// OpenAttacksAudit_CL: TimeGenerated(datetime), EventType/Actor/Asset/Action/Target/CorrelationId(string).
// Selects candidates only. Apply the stage hypothesis and correlation steps before alerting.
OpenAttacksAudit_CL
| where TimeGenerated > ago(7d)
| where EventType in ("secret.read", "credential.store.read")
| project TimeGenerated, EventType, Actor, Asset, Action, Target, CorrelationId
| order by TimeGenerated descSPL
sourcetype="openattacks:audit"
EventType IN ("secret.read", "credential.store.read")
| table _time EventType Actor Asset Action Target CorrelationId
| sort - _timeInvestigation steps
- Identify the actor, process and exact store touched, then pivot to token use from new devices or infrastructure.
- Correlate reads with egress and rotate affected credentials after confirming exposure.
Technical detailsTooling, impact & MITRE ATLAS
Attack context
- AI's role
- Agent / MCP as target
- Initial access
- User visits malicious website that drops AGENTS.md into ~/Downloads
Tooling as reported
AI products, models and artifacts
- Coding agents (Codex, Claude, others)
- Agent instruction files (AGENTS.md, CLAUDE.md)
- ~/.codex/config.toml
Other tooling
- function-color npm package (MALFEX downloader)
- OAuth token theft
Targets and reported impact
- Targets / sectors
- Software developers using AI coding agents
- Reported scale / exposure
- Proof of concept demonstrating attack vector; actual deployment scale unknown
- Target geography
- Multiple regions
Multiple regions reflects global developer population using coding agents
Source 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
MITRE ATLAS
AI-specific catalog annotations based on the reported behavior; these are not MITRE case-study assignments.
Malicious instruction file manipulates agent behavior by exploiting instruction file loading priority Source
AGENTS.md contains malicious instructions that modify agent configuration and install malware Source
Attack exfiltrates OAuth tokens via CLAUDE.md variant Source
Malicious instructions modify agent configuration files for persistence Source
Sources & research credit
1 sourceResearch by Gal Weizman, Omer Samet · Forever Security
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.
Record & downloads
- Source record name
- Malicious AGENTS.md hijacking coding agents via Downloads
- Entry ID
- forever-agents-md-hijack-2026
- Catalog review
- November 4, 2026
- AI-role confidence
- high