Hook
Block Curl Pipe Shell
A Claude Code hook that refuses commands which pipe curl or wget output into sh or bash, or run a downloaded script through a command substitution.
1node -e "let d='';process.stdin.on('data',c=>d+=c).on('end',()=>{let j={};try{j=JSON.parse(d)||{}}catch(e){process.exit(0)}const i=j.tool_input||{};const q=String.fromCharCode(34),sq=String.fromCharCode(39),bs=String.fromCharCode(92),nl=String.fromCharCode(10);const c=String(i.command||'');const sh='(a|ba|da|fi|k|z|c)?sh';const piped=c.split(/[;&]+/).some(s=>{const p=s.split('|');return p.some((x,k)=>k>0&&new RegExp('^(sudo[ ]+)?(env[ ]+)?'+sh+'([ ]|$)').test(x.trim())&&p.slice(0,k).some(y=>/(^|[ (])(curl|wget)[ ]/.test(y)))});const sub=new RegExp('(^|[ ;&|])'+sh+'[ ]+(-[a-z]+[ ]+)*.{0,4}[(][ ]*(curl|wget)[ ]').test(c)||new RegExp('(^|[ ;&|])('+sh+'|source|[.])[ ]+[<][(][ ]*(curl|wget)[ ]').test(c)||/(^|[ ;&|])eval[ ]+.{0,4}[(][ ]*(curl|wget)[ ]/.test(c);if(piped||sub){console.error('Blocked: this runs downloaded code without a look. Download the script to a file, read it, then run it, or ask the user to approve the source.');process.exit(2)}})"
Claude Code
Block Curl Pipe Shell
HookSecurity
Free