Skip to content

AAK-HOOK-006: Hook command runs with elevated privileges

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

What it detects

A hook command uses sudo, doas, pkexec, or chmod +x. Hooks should never require elevated privileges.

How to fix

Remove sudo, doas, pkexec and chmod +x from the hook command. A hook needs no elevated rights; to run a script, commit it with its executable bit set (git update-index --chmod=+x script.sh) instead of changing the mode from the hook.

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

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

Limitations

Matches sudo, doas, pkexec and chmod followed by whitespace and +x. chmod 755, chmod a+x and su root -c, which grant the same execute or root rights, are not matched. 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-006.md: the page then shows that text, with the registry reference appended under it.