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-vectors010-pda-confusion-type-cosplay.md

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

10 — PDA Confusion / Type Cosplay

Severity: 8 | Real: Multiple Solana exploits, Jet Protocol type confusion

Attacker creates an account with the same binary layout as an expected account type — passes validation, feeds malicious data.

Verification Procedure

Step 1: Check all account types use Anchor discriminator

grep -rn --include="*.rs" "#\[account\]" programs/*/src/state/
  • ✅ PASS: All state structs use #[account] (Anchor auto-adds 8-byte discriminator)
  • ❌ FAIL: Any state struct uses manual serialization without discriminator

Step 2: Verify Account<> type is used (not AccountInfo)

grep -rn --include="*.rs" "AccountInfo<" programs/*/src/instructions/ | grep -v "/// CHECK"
  • ✅ PASS: Zero results — all accounts are typed (Account<>, Program<>, Signer<>, UncheckedAccount with CHECK)
  • ❌ FAIL: Raw AccountInfo used without CHECK comment and runtime validation

Step 3: Verify PDA seeds include type-specific discriminators

grep -rn --include="*.rs" "seeds = \[" programs/*/src/instructions/
  • ✅ PASS: Seeds include a unique prefix per account type (e.g., b"fund", b"position", b"withdrawal")
  • ❌ FAIL: Multiple account types share the same seed pattern (collision possible)

Step 4: Check for AccountInfo used as typed account

grep -rn --include="*.rs" -B5 "AccountInfo\|UncheckedAccount" programs/*/src/instructions/ | grep -v "test"
  • For each: verify the comment explains WHY and that runtime validation exists
  • ✅ PASS: Each use has a valid reason and runtime owner/type check
  • ❌ FAIL: AccountInfo used for convenience, no validation

Step 5: Check has_one constraints prevent cross-type confusion

grep -rn --include="*.rs" "has_one" programs/*/src/instructions/
  • ✅ PASS: Accounts that reference each other use has_one to ensure type-correct linking
  • ❌ FAIL: Accounts can reference wrong types because has_one is missing

Step 6: Donor-overlay proof (native / Pinocchio / unchecked deserializers) List donor types (a caller can create or write them without privilege) and victim reads (privileged deserializations without a tag check). Overlay byte offsets; if attacker-controlled bytes land on an authority/amount/destination field, write the PoC (call the donor instruction, then the victim with the donor account). Borsh Vec/String/Option/enum fields make offsets data-dependent — compute them for the donor's chosen content. Tags must be unique, non-zero, written at init and checked in one shared loader (KV-159).

  • ✅ PASS: tag/discriminator checked before any field on every privileged read
  • ❌ FAIL: an overlay puts attacker bytes on a privileged field

Sources: Neodyme "Common Pitfalls", "Solana account confusions" section [paraphrased, cited: https://neodyme.io/en/blog/solana_common_pitfalls].

Overall verdict:

  • ✅: All accounts use Anchor discriminators, typed with Account<>, unique PDA seeds per type
  • ⚠️: Mostly correct but 1-2 UncheckedAccounts with adequate runtime checks
  • ❌: AccountInfo without validation, or shared PDA seeds between types

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