Claude Code file-guard hooks on 'Read' do not intercept Bash cat commands
A developer testing Claude Code's PreToolUse hook system found that hooks registered on the Read tool are never triggered when the model accesses a file via the Bash cat command instead. In controlled experiments run on Claude Code versions 2.1.246 and 2.1.258 on Linux, a blocker hook set to exit 2 on Read successfully stopped direct Read tool calls but was completely bypassed by cat, allowing the file's contents to reach the model. By contrast, a deny rule configured in settings.json blocked cat access to the specified file across both Read and Bash tool paths. A follow-up test confirmed the deny rule operates per-file rather than per-directory, despite misleading wording in the tool's response message. The findings, prompted by a GitHub issue filed on 2026-08-26, highlight a significant gap for users relying solely on PreToolUse hooks to keep sensitive files out of model context.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in