Urgent.News

What's breaking now, across thousands of outlets.

AI

Claude Code PreToolUse Hook: 80 of 91 Secret Blocks Were False Alarms

My agent was trying to keep secrets out of its own output. It ran grep -v "^./.env" to filter those lines away, and my Claude Code PreToolUse hook blocked it for touching a secret file. That made me wonder how often my security hook was right, so I parsed 31 days of transcripts: 820 sessions and 255,911 tool calls, 159,513 of them Bash. The hook had blocked 91 Bash commands. I read all 91 by…

Claude Code PreToolUse hook blocked 91 out of 159,513 Bash commands in 31 days, with 80 of those blocks being false alarms (88%). The hook blocks commands that target secret files or contain commands capable of printing file contents. However, the hook has a flaw as it checks for the presence of secret file names and potential dumpers separately, without requiring both conditions to be met within the same command.

This results in many false alarms as agents write complex command lines with multiple components. Additionally, 5 real secret file accesses slipped through the hook, as the agents were following instructions and the hook lacked context about human approval. To improve the hook, it should parse the command instead of using regex, allowing safe verbs and handling quoted strings properly.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in AI

Meet Gnito: Your AI. Your Machine. Your Rules.

Meet Gnito: Your AI. Your Machine. Your Rules. What if you could run your own AI workspace locally, choose your AI provider, and keep control of your data? That's what I'm building with Gnito .

  • Gnito is an open-source, self-hosted AI workspace
  • Supports multi-provider AI connections and local model endpoints
  • Features include AI chat, attachments, projects, and local memory storage

More from Saturday 7 November →