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-vectors178-atomic-outcome-revert.md

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

178 — Atomic Outcome Revert (Same-Transaction Settlement)

Severity: 8 (HIGH/CRITICAL when the treasury pays out above the house edge; MEDIUM when only fairness is affected) | Real: COPE Roulette (Arrowana): the author reports 207 wins out of 207 attempts

KV-120 is about predictable entropy. This works even with unpredictable entropy: if the outcome is observable and final inside the caller's atomic transaction, the caller makes the transaction conditional on it — a later instruction that only succeeds if the bet won, or a wrapper program that CPIs in and checks the result. Losses revert; only fees are paid. Simulate-then-send works whenever the entropy is the same in simulation and execution, and Jito bundles are all-or-nothing, so a later transaction in the same bundle can assert the result and drop the bundle on a loss even if the program rejects CPI callers and requires being the last instruction. Affects lotteries, loot boxes, mystery mints, gacha/trait rolls, random-winner auctions, "spin" or "claim a random reward" instructions.

Cross-ref: ECON-107, KV-120.

Verification Procedure
rg -n -i 'roll|spin|lottery|raffle|jackpot|loot|mystery|gacha|random|winner|reward_tier|rarity' programs/
rg -n -i 'request_randomness|commit|reveal|settle|consume_randomness|fulfill|pending_(bet|roll|request)' programs/
rg -n -i 'get_stack_height|TRANSACTION_LEVEL_STACK_HEIGHT|load_current_index_checked|get_instruction_relative' programs/
  • ✅ PASS: two-phase — tx A escrows a non-refundable stake and records a request; tx B (a later slot) settles via a permissionless or oracle-driven path with VRF output bound to the request; an unsettled request forfeits on timeout (otherwise the player declines to settle a known loss once the VRF output is public)
  • ❌ FAIL: one instruction derives the outcome and pays it; CPI-caller rejection and last-instruction checks alone (bundles and simulation still work)
// FIXED (shape)
pub fn request_spin(ctx: Context<RequestSpin>, bet: u64) -> Result<()> {
    escrow_stake(&ctx, bet)?;                         // locked now, not refundable on demand
    let req = &mut ctx.accounts.request;
    req.player = ctx.accounts.player.key(); req.bet = bet;
    req.request_slot = Clock::get()?.slot; req.state = RequestState::Pending;
    request_vrf(&ctx)                                 // fulfilled in a LATER tx
}
pub fn settle_spin(ctx: Context<SettleSpin>) -> Result<()> {  // permissionless / oracle callback
    let req = &mut ctx.accounts.request;
    require!(req.state == RequestState::Pending, ErrorCode::AlreadySettled);
    require!(Clock::get()?.slot > req.request_slot, ErrorCode::SameSlot);
    let r = verified_vrf_output_bound_to(req)?;       // KV-120
    req.state = RequestState::Settled;
    payout_or_forfeit(&ctx, r)
}
// plus: expire_request() — after a timeout, anyone can settle as a forfeit

Overall verdict: ✅ the outcome cannot be vetoed by the caller · ❌ revert-if-lose is possible

Sources: sannykim/solsec → COPE Roulette [paraphrased, cited: https://github.com/Arrowana/cope-roulette-pro], with added Jito-bundle and forfeit/permissionless requirements.

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