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-vectors120-onchain-randomness-predictability.md

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

120 — On-Chain Randomness Predictability & VRF Misbinding

Severity: 7 | Real: ToB Pyth Entropy audit (blockhash-zero → 2-outcome grind, reorg re-grinding); Zenith MagicBlock Ephemeral VRF (same-slot hash reuse)

On-chain programs that derive "randomness" from validator-observable or user-supplied entropy are predictable or grindable. Clock (unix_timestamp/slot), recent_blockhashes / SlotHashes, and caller-supplied seeds are all known to the transaction producer at build time — a lottery/NFT-mint/game program that picks a winner or trait from them lets the attacker only submit when the outcome favors them (or re-grind across a reorg). VRF integrations fail the same way when the returned randomness is not cryptographically bound to the specific consuming instruction/request (allowing result reuse across slots or callers) or is consumed without a staleness check. Commit-reveal schemes fail when the last revealer can compute the final value and abort (reveal-abort grinding) or when there is no economic penalty for non-reveal.

This is the on-chain class. The distinct web/off-chain case (Math.random() for session tokens/nonces) is out of scope for this skill. A program can be perfectly clean off-chain and still be exploitable here.

Verification Procedure

Step 1: Find on-chain entropy sources used as randomness

grep -rn --include="*.rs" -iE "recent_blockhashes|RecentBlockhashes|SlotHashes|slot_hashes|unix_timestamp|Clock::get|\.slot\b" programs/*/src/
  • Record every use feeding a winner-selection, trait roll, mint order, shuffle, or reward draw

Step 2: Classify each usage (grindable vs bound)

# For each hit: is the value known to the tx producer before/at submission?
grep -rn --include="*.rs" -iE "lottery|winner|jackpot|raffle|random|roll|shuffle|draw|pick|mint.*trait|rarity" programs/*/src/
  • ✅ PASS: selection uses a VRF result or a penalized commit-reveal — never raw slot/blockhash/Clock
  • ❌ FAIL: outcome derived from recent_blockhashes/slot/unix_timestamp/user seed (attacker submits only on favorable outcomes; reorg lets re-grind)

Step 3: If a VRF is used, verify request-binding + staleness

grep -rn --include="*.rs" -iE "switchboard|orao|vrf|randomness|reveal|consume_randomness" programs/*/src/
  • ✅ PASS: Switchboard/ORAO VRF result is bound to THIS request (request account/seed tied to the consuming instruction), fulfilled after the request slot, and rejected if stale/reused
  • ❌ FAIL: VRF result not bound to the request (reusable across callers/slots), or same-slot fulfillment allowed, or no staleness/one-time-consume guard

Step 4: If commit-reveal is used, verify anti-grinding economics

  • Confirm the reveal cannot be selectively aborted for advantage, and non-reveal is penalized (forfeited deposit / slashed stake) so the last revealer cannot grind by withholding
  • ✅ PASS: commitments are binding, all committers' contributions are required (or non-reveal is economically punished), final value not computable before all reveals
  • ❌ FAIL: last revealer can compute the result and abort with no penalty (reveal-abort grinding)

Overall verdict:

  • ✅: Request-bound VRF (Switchboard/ORAO) with staleness + one-time consume, OR penalized commit-reveal
  • ⚠️: VRF/commit-reveal present but missing staleness check or a clear non-reveal penalty
  • ❌: Any security- or value-relevant outcome derived from slot/blockhash/Clock/user seed, or a VRF result not bound to its request
  • N/A: Program performs no randomness-dependent selection

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