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-vectors145-tautological-constraints-unchecked-keys.md

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

145 — Tautological Constraints Anchored on Unchecked Keys

Severity: 8 | Real: Ackee Solana Auditors Bootcamp CTF level-5 (fake verification program); Solana Foundation Program Security course seeds::program example

Anchor constraints are only as strong as the key they compare against. When seeds::program = verifier.key(), owner = verifier.key(), address = x.key(), token::authority = x, or seeds = [.., x.key().as_ref()] take x from an AccountInfo/UncheckedAccount with no pin of its own, an attacker deploys their own "verifier", creates a PDA under it, and every constraint is satisfied. The struct looks heavily constrained, which is why review misses it. A CPI "verifier" or "oracle" passed as an unchecked account where the caller treats "the CPI returned Ok" as verification has the same shape (an attacker program always returns Ok). Native equivalents: find_program_address(seeds, unpinned_id) and create_program_address(seeds, acct.owner) (derives under whatever program owns the passed account, which the attacker chooses by passing an account their own program owns — circular).

Cross-ref: AV-110, PDA-024, AC-065, KV-009 (first-order unchecked CPI target).

Verification Procedure

Step 1: Collect unchecked accounts, then constraints that trust their keys

rg -n -o "pub ([a-z_]+): (AccountInfo|UncheckedAccount)<'info>" programs/
# for each name N:
rg -n "(seeds::program|owner|address|token::authority|mint::authority|associated_token::authority)\s*=\s*N(\.key\(\))?" programs/
rg -n "seeds\s*=\s*\[[^]]*N\.key\(\)" programs/
rg -n "(find|create)_program_address\([^)]*,\s*(&?\*?[a-z_]+\.owner|[a-z_]+\.key)\)" programs/
rg -n -A1 "/// CHECK:.*(checked|verified|safe).*(program|later|below|CPI)" programs/

Step 2: Pins

  • ✅ PASS: the right-hand side comes from Program<'info, T>, address = KNOWN_ID, or a canonical PDA/ProgramData check; every /// CHECK: that claims "checked elsewhere" points at a real check
  • ❌ FAIL: any constraint's key comes from an unpinned account
// VULNERABLE: both checks are relative to an attacker-chosen program
/// CHECK: "checked in program" (it is not)
pub verifier: AccountInfo<'info>,
/// CHECK: validated by the verifier
#[account(seeds = [b"gs", user.key().as_ref()], bump, seeds::program = verifier.key(), owner = verifier.key())]
pub guardian_set: AccountInfo<'info>,

// FIXED: pin the program first; everything derived from it becomes meaningful
pub verifier: Program<'info, VerificationProgram>,        // or #[account(address = verification_program::ID)]
/// CHECK: address and owner pinned to the known program
#[account(seeds = [b"gs", user.key().as_ref()], bump,
          seeds::program = verification_program::ID, owner = verification_program::ID)]
pub guardian_set: AccountInfo<'info>,

Report wording: describe the whole chain (unchecked account → constraint inherits trust → value moved) so the finding is not dismissed as "it has owner = and seeds::program".

Overall verdict:

  • ✅: every constraint key is pinned
  • ❌: any constraint inherits trust from an unpinned key on a value-moving or privileged path

Sources: Ackee-Blockchain Solana-Auditors-Bootcamp Capture-the-Flag/level-5 [paraphrased, cited: https://github.com/Ackee-Blockchain/Solana-Auditors-Bootcamp/tree/master/Capture-the-Flag/level-5]; Solana Foundation Program Security course arbitrary-cpi.md (seeds::program) [paraphrased, no licence, https://github.com/solana-foundation/developer-content/tree/main/content/courses/program-security].

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