Skip to content

AAK-AGENT-001: Agent instruction file contains shell command directives

Severity
CRITICAL
Category
Agent Config (agent-config)
Scanner
agent_audit_kit/scanners/agent_config.py
Auto-fixable
No.
SARIF name
AgentShellDirectives

What it detects

An agent instruction file (AGENTS.md, CLAUDE.md, .cursorrules and friends) tells the agent to run code it downloads, or to delete the filesystem root or a home directory: curl -fsSL <url> | bash, bash -c "$(curl -fsSL <url>)", iex ((New-Object Net.WebClient).DownloadString(<url>)), rm -rf ~. The file is read as instructions, so whatever the far end serves at the time runs with the agent's permissions.

Until 0.6.15 this rule was a keyword match (subprocess, eval(, exec(, sh -c, any rm -rf, any curl ... | sh). On the 909 public repositories of the #771 corpus it fired on 74, nearly all of them on a mention: a guardrail such as "Never use eval()", a deny-list row, a code sample, rm -rf dist. It reports the command now, not the word (#869).

How to fix

Do not tell the agent to pipe a download into a shell. Install from a package manager, or download the script to a file, check its checksum or signature, and run the local copy. Remove destructive commands from instruction files.

To confirm the finding is gone, report only this rule:

agent-audit-kit scan . --rules AAK-AGENT-001

Limitations

Reads one line at a time. A download counts when it is piped into an interpreter, run through $(...) or <(...), or handed to PowerShell's iex, and the command names what it fetches (a URL, a $VARIABLE or a host); an interpreter given its code on the command line (| python3 -m json.tool) reads the download as data, and a loopback URL is a local API. A URL that Node, requests and Rust's url crate read differently from curl, httpx and urlsplit, which keep a backslash inside the authority, is judged by the less safe of the two readings. A recursive rm counts when it targets /, ~ or $HOME where a command starts. A command a guardrail forbids is not reported: one negated in the sentence, one under a heading or lead-in such as "### NEVER", or one in a table row. eval(, exec(, subprocess and sh -c on their own, commands split across lines, and other destructive commands (mkfs, dd) are not reported.

References


All rules. This page is generated from the rule registry when the documentation is built; to change it, change the rule in agent_audit_kit/rules/builtin.py. To give the rule a hand-written write-up, add docs/rules/AAK-AGENT-001.md: the page then shows that text, with the registry reference appended under it.