Skip to content

AAK-HOOK-007: Excessive number of hooks defined

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

What it detects

More than 15 hook definitions in a single settings file. Large hook surface increases audit burden and risk of hidden malicious hooks.

How to fix

Remove hooks that are not essential, or fold related ones into one script, until each file has 15 or fewer hooks. The rule counts every hook, each one in a matcher group's hooks array on its own, in each settings file, plugin hooks/hooks.json and SKILL.md separately, and fires above 15.

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

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

Limitations

Counts the hooks of all events in one file (a settings file, a plugin's hooks/hooks.json or a SKILL.md), each hook in a matcher group's hooks array separately, and fires above 15. Hooks split between files, such as .claude/settings.json and .claude/settings.local.json, are not added up, and hooks a plugin declares in .claude-plugin/plugin.json or a subagent in its frontmatter are not counted.

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