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-vectors161-vault-return-to-zero-residual.md

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

161 — Vault Return-to-Zero Residual Capture

Severity: 7 (higher when residual value is large or the vault re-opens predictably) | Real: Plamen zero-state-return audit class

First-depositor protections (ECON-013..017/069, KV-006) usually run at genesis. A vault can return to total_shares == 0 after everyone exits while value remains: accrued-but-undistributed rewards, locked/streaming profit, fee balances, high-water marks, rounding dust in the PDA token account. The next depositor then meets the first-depositor condition on a pre-seeded vault, often without the protections that ran only in initialize. Default-zero timestamps (last_update = 0) on re-entry also make now - last_update enormous and can drive accrual or decay math.

Cross-ref: ECON-098, invariant-catalog §11, KV-006, KV-017.

Verification Procedure
rg -n 'total_shares\s*==\s*0|supply\s*==\s*0|shares\s*=\s*amount' programs/
rg -n 'locked_profit|acc_reward_per_share|pending_fees|high_water_mark|last_report|last_update' programs/
rg -n 'VIRTUAL_|DEAD_SHARES|MINIMUM_LIQUIDITY' programs/
  • Can supply reach exactly 0 (are dead shares burned only in initialize, or is the protection keyed to !initialized)?
  • On supply 0, which fields survive? Compute the exchange rate for a 1-unit re-entry with that residual.
  • ✅ PASS: virtual offsets/dead shares apply on every mint path; residual value is swept or distributed when supply hits 0; timestamps reset on re-entry
  • ❌ FAIL: 1:1 minting on total_shares == 0 while residual value remains claimable
// VULNERABLE: residual rewards persist; 1:1 mint on empty supply
if vault.total_shares == 0 { shares = amount; }

// FIXED: rate always includes virtual offsets; u128 checked math; round shares DOWN on mint
let num = (amount as u128)
    .checked_mul((vault.total_shares as u128).checked_add(VIRTUAL_SHARES).ok_or(ErrorCode::Math)?)
    .ok_or(ErrorCode::Math)?;
let den = (vault_assets as u128).checked_add(VIRTUAL_ASSETS).ok_or(ErrorCode::Math)?;
let shares = u64::try_from(num.checked_div(den).ok_or(ErrorCode::Math)?).map_err(|_| ErrorCode::Math)?;

Overall verdict:

  • ✅: no residual is claimable by the next minter at an unprotected rate
  • ❌: return-to-zero reopens first-depositor extraction

Sources: PlamenTSV/plamen agents/skills/solana/zero-state-return/SKILL.md (MIT, Copyright (c) 2025-2026 Plamen Contributors); fixed formula rewritten with u128 checked math.

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