Learn Solana security through vulnerable and secure implementations with real exploit demonstrations.
5 production-grade programs demonstrating critical security vulnerabilities:
- Multisig (Anchor) - Multi-signature wallet (4 Critical vulnerabilities)
- Governance (Anchor) - Reputation-based DAO (6 Critical, 3 High, 2 Medium)
- AMM (Anchor) - Automated Market Maker (9 Critical, 2 High, 3 Medium)
- Escrow (Pinocchio) - Atomic token swap escrow
- NFT Minting (Anchor) - On-chain NFT minting with Metaplex Core
Each program includes side-by-side secure/vulnerable implementations with comprehensive tests.
git clone https://github.com/AlphaR2/Soteria.git
cd Soteria# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
# Install Solana CLI (v2.0+)
sh -c "$(curl -sSfL https://release.anza.xyz/stable/install)"
# Install Anchor CLI (v0.32.1+) - for Anchor programs
cargo install --git https://github.com/coral-xyz/anchor avm --force
avm install latest
avm use latest# Make executable (first time only)
chmod +x test-runner.sh
# Launch interactive menu
./test-runner.shThe test runner provides:
- Build all programs or individual versions
- Run secure tests (exploits prevented)
- Run exploit tests (attacks succeed)
- Execute all test suites sequentially
- Color-coded output with progress indicators
Each program directory contains:
README.md- Architecture, vulnerabilities, attack scenariosVULNERABILITIES.md- Detailed security analysisTESTING.md- Testing guide and examples- Side-by-side secure/vulnerable implementations
All vulnerabilities are classified using this standard:
Bugs that cause direct loss of funds with minimal setup. Attacker can trigger with little preparation or even accidentally. Effects are difficult to undo after detection.
Examples: Missing signer checks, arbitrary CPI, uninitialized account exploits
Bugs that enable loss of funds with preparation, or render the contract unusable/DOS (or in a locked-out state).
Examples: Missing authorization checks, reentrancy, integer overflow
Bugs that don't cause direct fund loss but lead to exploitable mechanisms.
Examples: Weak validation, precision loss, missing slippage protection
Bugs with no significant immediate impact, easily fixed after detection. This can also include wrong decisions in code, not harmful, just best practices.
Examples: Suboptimal gas usage, missing events, incomplete error messages
Tests are properly implemented in each program with LiteSVM for fast testing. You can cd into any of the folders and run tests.
Soteria/
├── programs/
│ ├── multisig/ # Multi-signature wallet (Anchor)
│ │ ├── m-secure/ # Secure implementation
│ │ │ ├── src/ # 4 instructions, 40+ security checks
│ │ │ └── tests/ # 4 comprehensive tests
│ │ ├── m-vulnerable/ # Vulnerable implementation
│ │ │ ├── src/ # Missing critical checks
│ │ │ ├── tests/ # 4 exploit demonstrations
│ │ │ └── VULNERABILITIES.md
│ │ └── README.md # Side-by-side comparison
│ │
│ ├── governance/ # Reputation-based DAO (Anchor)
│ │ ├── g-secure/ # Secure implementation
│ │ │ ├── src/ # 8 instructions, 50+ security checks
│ │ │ └── tests/ # 5 comprehensive tests
│ │ ├── g-vulnerable/ # Vulnerable implementation
│ │ │ ├── src/ # 10+ intentional vulnerabilities
│ │ │ ├── tests/ # 6 exploit demonstrations
│ │ │ └── VULNERABILITIES.md
│ │ └── README.md # Side-by-side comparison
│ │
│ ├── amm/ # Automated Market Maker (Anchor)
│ │ ├── amm-secure/ # Secure implementation
│ │ │ ├── src/ # 6 instructions, 30+ security checks
│ │ │ └── tests/ # 5 comprehensive tests
│ │ ├── amm-vulnerable/ # Vulnerable implementation
│ │ │ ├── src/ # 14 intentional vulnerabilities
│ │ │ ├── tests/ # 7 exploit demonstrations
│ │ │ ├── VULNERABILITIES.md
│ │ │ └── TESTING.md
│ │ └── README.md # Side-by-side comparison
│ │
│ ├── pino-escrow/ # Atomic swap escrow (Pinocchio)
│ │ ├── p-vulnerable/ # Shows security flaws
│ │ ├── p-secure/ # Shows fixes
│ │ └── README.md # Vulnerabilities explained
│ │
│ └── nfts/ # NFT minting (Anchor + Metaplex Core)
│ ├── n-secure/ # Secure implementation
│ ├── n-vulnerable/ # Vulnerable implementation
│ └── README.md
│
├── test-runner.sh # Run all tests across all programs
│
└── README.md # This file
| Program | Framework | Vulnerabilities | Test Count |
|---|---|---|---|
| Multisig | Anchor | 4 Critical | 4 secure + 4 exploit |
| Governance | Anchor | 6 Critical, 3 High, 2 Medium | 5 secure + 6 exploit |
| AMM | Anchor | 9 Critical, 2 High, 3 Medium | 5 secure + 7 exploit |
| Escrow | Pinocchio | 4 | 3 |
| NFT Minting | Anchor + Metaplex | 5 | 5 |
See individual program READMEs for:
- Detailed vulnerability documentation
- Attack scenario walkthroughs
- Side-by-side security comparisons
- Complete test documentation
All programs use LiteSVM for fast Rust-based testing:
- No validator required
- Tests run instantly in Rust
- Comprehensive exploit demonstrations
- Side-by-side secure vs vulnerable comparisons
Each test follows: Setup → Exploit → Result → Impact → Lesson
Run tests via the interactive test runner (recommended) or manually from program directories.
- Multisig → Basic security (signer checks, threshold validation)
- Governance → State management, cooldowns, reputation systems
- AMM → DeFi mechanics, slippage, economic attacks
- Escrow → Pinocchio framework patterns
- NFT Minting → Metaplex integration
| Category | Examples |
|---|---|
| Authorization | Missing signer checks, owner validation, RBAC |
| Validation | Input boundaries, state transitions, account ownership |
| Economic | Slippage manipulation, inflation attacks, front-running |
| Arithmetic | Integer overflow/underflow, precision loss |
| State | Uninitialized accounts, replay attacks, missing cooldowns |
| Time-based | Expiration validation, cooldown enforcement, stale transactions |
- Defense in Depth - Validate explicitly even when lower layers enforce constraints
- Least Privilege - Verify every signer, check every authority, validate every account
- Fail Securely - Reject by default, use allow-lists, handle all errors
- Validate Everything - Inputs, account data, time parameters, arithmetic, state
WARNING: These programs contain intentionally vulnerable code for educational purposes.
- Vulnerable versions should NEVER be deployed to production
- Demonstrates real-world attack vectors found in production systems
- Use secure versions as reference implementations only
- Always perform thorough audits before mainnet deployment
This repository is for learning and security education only. Coming Next: Lending Protocol • Staking • Oracle • More governance patterns