AAK-HOOK-008: Hook command contains obfuscated or encoded payload
- Severity
- CRITICAL
- Category
- Hook Injection (
hook-injection) - Scanner
agent_audit_kit/scanners/hook_injection.py- Auto-fixable
- No.
- SARIF name
HookObfuscatedPayload
What it detects
A hook command contains hex-encoded strings, unicode escapes, an embedded base64 blob or nested shell invocations. Obfuscation is a strong indicator of malicious intent.
How to fix
Rewrite the hook so its command is plain: remove \xNN and \uNNNN escapes and nested sh -c ... sh -c chains, and replace an embedded base64 blob (64 or more letters, digits, + or = in a row, mixing upper case, lower case and digits) with the command it encodes, or with a script file in the repository that the hook calls by path, where it can be reviewed. Length alone does not fire the rule.
To confirm the finding is gone, report only this rule:
agent-audit-kit scan . --rules AAK-HOOK-008
Limitations
Matches \x41 and \u0041 escapes, sh -c twice in one command (inside bash -c too), and an unbroken run of 64 or more letters, digits, + or = that mixes upper case, lower case and digits, as base64 does. A hex digest (an image pinned @sha256:) and a long readable command are not reported, and a base64 blob whose / characters split it into runs shorter than 64 is missed. The same text written as bash octal escapes ($'\143\165\162\154') or reassembled from shell variables ($a$b) is 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-OBFUSC-02 (Obfuscated Hook Payload)
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-008.md: the page then shows that text, with the registry reference appended under it.