This repository is a compact, educational reference of nine real-world Solana security patterns. Each module shows the same business intent implemented two ways:
vulnerable.rs— intentionally broken logicsecure.rs— corrected, defensive logic
The goal is to make security mistakes obvious, reproducible, and easy to explain in code reviews or audits.
README.md
LICENSE
docs/deep-dive.md
examples/
01_missing_authority/
02_missing_signer/
03_fake_account/
04_pda_misuse/
05_state_order/
06_cpi_trust/
07_cpi_reentrancy/
08_overflow/
09_insecure_close/
examples/01_missing_authority— Missing authority checkexamples/02_missing_signer— Missing signer requirementexamples/03_fake_account— Fake account injection (owner not verified)examples/04_pda_misuse— PDA misuse (seeds/bump not enforced)examples/05_state_order— State mutation before validationexamples/06_cpi_trust— Unsafe CPI trustexamples/07_cpi_reentrancy— Re-entrancy via CPIexamples/08_overflow— Integer overflow/underflowexamples/09_insecure_close— Insecure account close / lamport drain
Each folder includes:
README.md— description of the vulnerability and fixvulnerable.rs— intentionally unsafe version with commentssecure.rs— corrected version with comments
These examples are intentionally minimal and focus on the security pattern, not full program scaffolding.
For a longer-form explanation of the patterns and why they matter, see docs/deep-dive.md.