Learn about common security vulnerabilities in Solana programs and how Anchor helps prevent them.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/solana-foundation/anchor/llms.txt
Use this file to discover all available pages before exploring further.
Missing signer checks
Vulnerability: Not verifying that an account signed the transaction. Anchor protection: UseSigner<'info> type.
Missing ownership checks
Vulnerability: Not verifying account ownership. Anchor protection:Account<'info, T> automatically checks owner.
Missing account validation
Vulnerability: Not validating account relationships. Anchor protection: Usehas_one and constraint.
Arithmetic overflow/underflow
Vulnerability: Integer overflow causing unexpected behavior. Anchor protection: Use checked arithmetic.Reinitialization attacks
Vulnerability: Allowing accounts to be reinitialized. Anchor protection:init constraint prevents reinitialization.
PDA validation
Vulnerability: Not validating PDA derivation. Anchor protection: Useseeds and bump constraints.
Account closing vulnerabilities
Vulnerability: Not properly closing accounts or returning lamports to wrong address. Anchor protection: Useclose constraint.
Duplicate mutable accounts
Vulnerability: Same account passed multiple times as mutable. Anchor protection: Anchor prevents duplicate mutable accounts by default (0.32+).Type confusion
Vulnerability: Treating one account type as another. Anchor protection: Account discriminators prevent this.Best practices checklist
Before deploying:- All signers use
Signer<'info>type - All accounts use appropriate Anchor types
- All account relationships validated with
has_one - All custom logic uses
constraint - Arithmetic uses checked operations
- PDAs use
seedsandbumpconstraints - Account closes use
closeconstraint - No
UncheckedAccountwithout/// CHECK:comment - All error cases handled
- Tests cover security scenarios
Security audits
For production programs:- Self-audit using this checklist
- Peer review with experienced Solana developers
- Professional audit from security firms like:
- OtterSec
- Sec3
- Neodyme
- Trail of Bits
Learn more
Sealevel attacks
Common Solana vulnerabilities
Security guide
Anchor security patterns