Skip to main content
Learn about common security vulnerabilities in Solana programs and how Anchor helps prevent them.

Missing signer checks

Vulnerability: Not verifying that an account signed the transaction. Anchor protection: Use Signer<'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: Use has_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: Use seeds and bump constraints.

Account closing vulnerabilities

Vulnerability: Not properly closing accounts or returning lamports to wrong address. Anchor protection: Use close 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 seeds and bump constraints
  • Account closes use close constraint
  • No UncheckedAccount without /// CHECK: comment
  • All error cases handled
  • Tests cover security scenarios

Security audits

For production programs:
  1. Self-audit using this checklist
  2. Peer review with experienced Solana developers
  3. Professional audit from security firms like:
    • OtterSec
    • Sec3
    • Neodyme
    • Trail of Bits

Learn more

Sealevel attacks

Common Solana vulnerabilities

Security guide

Anchor security patterns