Index of every page on this site: llms.txt
All skills
princedotrs avatar

/solana-program-audit

@586e19e
Run it yourself

Security audit of Solana on-chain programs in Rust: Anchor, native solana-program and Pinocchio. Use to audit or review a Solana program, PR or fix and to find vulnerabilities: missing signer or owner checks, account validation, type cosplay, reinitialization, init front-running, closed-account revival, duplicate accounts, PDA seeds and bumps, arbitrary CPI, CPI return data, remaining_accounts, sysvar and instruction introspection, overflow, rounding, Token-2022 extensions and transfer hooks, oracle, flash-loan and MEV attacks, upgrade authority and governance. Covers DeFi reviews (AMM, lending, perps, staking, bridges, launchpads), PoC exploits, fix patches, re-audits, spec compliance, audit readiness, release gates and audit reports. Trigger on code using anchor_lang, solana_program, pinocchio, #[program], #[derive(Accounts)] or entrypoint!. Not for writing features, off-chain clients or backends, EVM/Solidity, or incident response.

  • 237 files
  • 2 MB
  • Updated 4 weeks ago
  • GitHub
Use this Skill: https://skilld.dev/gh/princedotrs/solana-audit/solana-program-audit

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

known-vectors157-anchor-optional-account-gate-bypass.md

≈609 tokens on demand. Your agent reads this file only when SKILL.md points to it.

157 — Anchor Optional-Account Gate Bypass

Severity: 8 | Real: Anchor optional-accounts convention (the executing program's own id encodes None)

With Option<Account<'info, T>> (and Option<Signer>, Option<UncheckedAccount>, …), the client decides whether the account is present. It passes the program's own id as a placeholder, which decodes as None. Omitting trailing optional accounts also decodes as None, but only when anchor-lang's allow-missing-optionals feature is on. That feature is off by default, and then a missing account fails with AccountNotEnoughKeys. Constraints on the field run only when it is Some. A mandatory check written as if let Some(x) = … { check } therefore becomes voluntary; typical victims are allowlist entries, fee configs, oracles, referrer caps and KYC records. (The program's own id always decodes as None, so it can never be passed as a real Some.) <!-- verified: anchor v1.2.1 and v0.29.0 lang/src/accounts/option.rs: `if accounts.is_empty()` returns `Ok(None)` only under `cfg!(feature = "allow-missing-optionals")`, else `AccountNotEnoughKeys`; `if accounts[0].key == program_id { Ok(None) }` -->

Cross-ref: AN-004.

Verification Procedure
rg -n 'Option<(Box<)?(Account|InterfaceAccount|Signer|UncheckedAccount|AccountLoader|Program)' programs/
rg -n 'if let Some\(.*ctx\.accounts\.|\.as_ref\(\)\.map|\.is_none\(\)' programs/
  • ✅ PASS: wherever policy requires the account (the pool is gated, the fee applies), the handler requires Some (ok_or(ErrorCode::Required)?) before applying the check
  • ❌ FAIL: passing None skips a gate, fee or cap
// VULNERABLE
#[account(seeds = [b"allow", user.key().as_ref()], bump)]
pub allow_entry: Option<Account<'info, AllowEntry>>,
// if let Some(e) = &ctx.accounts.allow_entry { require!(e.active, ErrorCode::NotAllowed); }   // None skips the gate

// FIXED
if pool.gated {
    let e = ctx.accounts.allow_entry.as_ref().ok_or(ErrorCode::AllowEntryRequired)?;
    require!(e.active, ErrorCode::NotAllowed);
}

Overall verdict:

  • ✅: no required check depends on the caller choosing Some
  • ❌: a required check does

Sources: solana-foundation/solana-dev-skill skills/solana-dev/references/programs/design-patterns.md (Anchor Option gotcha) (MIT, Copyright (c) 2026).

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at 586e19e. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 weeks ago.

Activeupdated 4 weeks ago

README badge

README badge for princedotrs/solana-audit