Skip to content

AAK-HOOK-RCE-002: Hook runs with shell=True and variable interpolation

Severity
CRITICAL
Category
Hook Injection (hook-injection)
Scanner
agent_audit_kit/scanners/hook_rce.py
Auto-fixable
No.
SARIF name
HookShellTrue

What it detects

A hook script invokes subprocess.run / spawn with shell=True (or the equivalent in Node/Bash) while passing a composed string that includes caller-provided fields.

How to fix

Use shell=False and pass argv as a list. If a shell is needed, build commands from quoted constants only.

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

agent-audit-kit scan . --rules AAK-HOOK-RCE-002

Limitations

Matches shell=True before the first closing parenthesis of a subprocess.run, call, Popen or check_output call, and shell: true as any option of a Node spawn, spawnSync, child_process.exec or child_process.execSync call ({ cwd: dir, shell: true }), in a .sh, .bash, .py, .js, .ts or .mjs script under .claude/.../hooks/. A call with another call ahead of the option (subprocess.run(build(cmd), shell=True), spawn(String(cmd), [], { shell: true })), a quoted key ({ "shell": true }), shell: true passed to execFile or to exec called by its bare name, subprocess.check_call, and os.system and os.popen, which always use a shell, are not matched. A settings file over 1 MB, or a hook script over 512 KB, is not read.

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-HOOK-RCE-002.md: the page then shows that text, with the registry reference appended under it.