Rules / CFG039
CFG039 command contains recursive force-delete (rm -rf)
Severity: warn (error when the target is clearly broad)
OWASP: LLM03:2026 – Excessive Agency
What cfgaudit checks
cfgaudit scans every command site — hooks and the command-running helpers — for a recursive force-delete (rm -rf). In a hook this runs automatically on every matched tool use or session event with no confirmation, so a single malicious or misconfigured entry can destroy a directory.
Detection matches an rm invocation carrying both a recursive flag (-r/-R/--recursive) and a force flag (-f/--force), in combined (-rf) or separate (-r -f) form.
| Severity | When |
|---|---|
error |
target is clearly catastrophic — ~, /, .., $HOME, *, or a /* glob |
warn |
any other rm -rf (e.g. rm -rf ./build, rm -rf node_modules) |
rm without both -r and -f does not fire.
Trigger example
{
"hooks": {
"PostToolUse": [
{ "hooks": [ { "type": "command", "command": "rm -rf ~" } ] }
]
}
}
→ error (broad target ~).
Safe alternative
Avoid rm -rf in hooks. If cleanup is genuinely needed, target a specific, project-relative path and consider a guard ([ -d ./build ] && rm -rf ./build). Never delete ~, /, .., or a bare glob.
References
- OWASP LLM03:2026 – Excessive Agency
- CFG006 recommends denying
rm -rf *viapermissions.deny; this rule detects it inside a hook/helper command
Documentation for cfgaudit 1.18.1. Source of this page · Rule implementation