AAK-HOOK-RCE-001: Hook command interpolates user-controlled input
- Severity
- CRITICAL
- Category
- Hook Injection (
hook-injection) - Scanner
agent_audit_kit/scanners/hook_rce.py- Auto-fixable
- No.
- SARIF name
HookRceInterpolation
What it detects
A Claude Code hook script command-string interpolates a variable or captured group directly into a shell command. This is the CVE-2025-59536 shape: a poisoned config file triggers arbitrary code execution.
How to fix
Never interpolate hook input into a shell string. Use an argv list and a no-shell exec. Quote with shlex.quote if a shell is absolutely required.
To confirm the finding is gone, report only this rule:
agent-audit-kit scan . --rules AAK-HOOK-RCE-001
Limitations
Reads command strings in the Claude Code settings files, and .sh, .bash, .py, .js, .ts or .mjs scripts under a hooks directory inside .claude/, looking for ${, $(, a backtick, {{, %{ or a string + directly before a name beginning input, args, event, payload, user, argv or request. In a .py, .js, .ts or .mjs script that counts only when the same file also contains one of the texts subprocess.<name>, os.system, os.popen, commands.getoutput, child_process, execSync, spawnSync, the word exec or execa, spawn(, Deno.run, sh -c, bash -c or os.exec, called or not, so a wrapper such as execute(...) does not count. The same script kept outside .claude/hooks/ (scripts/guard.sh) or under another extension (guard.zsh) is not read, and a plain $cmd filled from jq is not matched. A settings file over 1 MB, or a hook script over 512 KB, is not read.
References
- CVE: CVE-2025-59536
- OWASP Agentic Top 10: ASI05 (Unexpected Code Execution (RCE))
- Adversa AI MCP Top 25 (AAK-defined ids): ADV-RCE-01
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-HOOK-RCE-001.md: the page then shows that text, with the registry reference appended under it.