Menu

Stop Claude Code from running curl | bash with a PreToolUse hook
📰

Stop Claude Code from running curl | bash with a PreToolUse hook

DEV Community: productivity·Vildanden·19 days ago
#W3ZPjE6K
#devtoproductivity#devto#dev#command#claude
Long article (315 words) — no AI summary yet.
Reading 0:00
15s threshold

Permission rules and secret-path guards still leave a hole: a Bash tool call can download a script and pipe it into a shell. A small PreToolUse hook stops that pattern before the command runs.

The hook

Save this as .claude/hooks/block-curl-pipe.sh and make it executable ( chmod +x ):

#!/usr/bin/env bash # Reads the tool call as JSON on stdin; exit code 2 blocks it. cmd = $( jq -r '.tool_input.command // ""' )

if echo "$cmd" | grep -Ei 'curl.+\|[[:space:]]*(sudo[[:space:]]+)?(ba)?sh|wget.+\|[[:space:]]*(sudo[[:space:]]+)?(ba)?sh|curl.+\|[[:space:]]*python' ; then echo "Blocked: that command looks like a remote script piped into a shell.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.