Skip to content

AAK-HOOK-004: Hook runs a command on tool use, prompt submit or session start

Severity
LOW
Category
Hook Injection (hook-injection)
Scanner
agent_audit_kit/scanners/hook_injection.py
Auto-fixable
No.
SARIF name
HookSensitiveLifecycleEvent

What it detects

A hook runs a command on PreToolUse, PostToolUse, SessionStart or UserPromptSubmit, so it runs automatically around tool calls, on every prompt and at session start. This is an inventory entry, not evidence of harm: the rule reads only the event and whether the command names a formatter, not what the command or a script it calls does. Review what it runs.

How to fix

Review what the command runs, including any script it calls. Keep the hooks you can account for and remove the rest.

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

agent-audit-kit scan . --rules AAK-HOOK-004

Limitations

Fires only for a hook on PreToolUse, PostToolUse, SessionStart or UserPromptSubmit whose command names none of a list of formatters. The same command on any other event, such as Stop, is not reported, and a command that merely contains a formatter name anywhere, even in a trailing comment (# prettier), counts as a formatter. A hook that runs no command (http, prompt, agent, mcp_tool) is not reported on any event. Hooks a plugin declares in .claude-plugin/plugin.json and hooks in a subagent's frontmatter are 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-004.md: the page then shows that text, with the registry reference appended under it.