AAK-HOOK-009: Hook command references project source files
- Severity
- MEDIUM
- Category
- Hook Injection (
hook-injection) - Scanner
agent_audit_kit/scanners/hook_injection.py- Auto-fixable
- No.
- SARIF name
HookReferencesSourceFiles
What it detects
A hook command reads or references project source code files, which could enable code exfiltration.
How to fix
Remove the cat, head, tail, less, more, grep, sed or awk call, or the < redirect, that reads a .py, .js, .ts, .go, .rs, .java, .rb, .c, .cpp or .h file in the hook command. If the hook needs the source for a check, run the project's own linter or formatter on the file instead of reading its contents.
To confirm the finding is gone, report only this rule:
agent-audit-kit scan . --rules AAK-HOOK-009
Limitations
Matches a file a reader command reads: an operand of cat, head, tail, less or more, a file operand of grep, sed or awk (never the pattern or program), or a < file redirect, ending in a lower-case .py, .js, .ts, .go, .rs, .java, .rb, .c, .cpp or .h, also inside sh -c. A pattern that names an extension (grep '\.py$') is not a read. Archiving or copying source (tar czf out.tgz src/, cp src/main.py out/) and reading a file of another type (cat src/App.tsx) are not matched. Hooks a plugin declares in .claude-plugin/plugin.json and hooks in a subagent's frontmatter are not read.
References
- OWASP Agentic Top 10: ASI05 (Unexpected Code Execution (RCE))
- Adversa AI MCP Top 25 (AAK-defined ids): ADV-EXFIL-02 (Source File Exfiltration)
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-009.md: the page then shows that text, with the registry reference appended under it.