Claude Code PreToolUse hooks bypassed via package.json edits

formal.ai23 min read

An analysis of Claude Code PreToolUse hooks tests their effectiveness as a security guardrail against allowlisting bypasses, finding that they fail to stop attacks where the danger lives outside the inspected command string, such as in package.json modifications or indirect executions. The author demonstrates that hooks can be bypassed through various file edits, repository settings like disableAllHooks, and unhandled failure modes, concluding that hooks should not be trusted as a hard security boundary. Open article →