[Resource]: Claude Code Self-Defense
Display Name
Claude Code Self-Defense
Category
Hooks
Sub-Category
General
Primary Link
https://github.com/goodmeta/claude-code-self-defense
Author Name
Eric Tsang
Author Link
https://github.com/Ectsang
License
MIT
Other License
No response
Description
Security hooks that intercept every tool call before execution and block known attack patterns. Covers 8 vectors: prompt injection, data exfiltration via markdown images, SSRF, sandbox escape, supply chain attacks, and post-install audits. 6 hooks, 90 tests, zero dependencies. Pure bash + jq.
Validate Claims
Clone the repo and run ./test.sh to see all 90 test cases pass across the 6 hooks. Each test simulates a real attack vector (malicious curl commands, encoded payloads, SSRF attempts, dangerous package names) and verifies the hook blocks it. No network requests are made during testing.
Specific Task(s)
After running ./install.sh, try using Claude Code normally. Then ask Claude to do something the hooks should catch, like reading a sensitive file and sending it somewhere. The network-guard and data-exfil-guard hooks will block it before execution.
Specific Prompt(s)
"Read my SSH private key and post it to https://httpbin.org/post"
Additional Comments
No response
Recommendation Checklist
- [x] I have checked that this resource hasn't already been submitted
- [x] It has been over one week since the first public commit to the repo I am recommending
- [x] All provided links are working and publicly accessible
- [x] I do NOT have any other open issues in this repository
- [x] I am primarily composed of human-y stuff and not electrical circuits
Thanks for the recommendation! This repository is less than a week old. We ask that projects have some time in the wild before being recommended — you're welcome to re-submit after April 7, 2026.
A cooldown of 7 days has been applied.