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-vectors006-first-depositor-share-inflation.md

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

6 — First Depositor / Share Inflation

Severity: 9 | Real: Multiple ERC-4626 vault exploits (2022-2023), Yearn-like vault attacks

Attacker deposits 1 lamport → donates large amount to vault → next depositor's shares round to 0 → attacker redeems all.

Verification Procedure

Step 1: Find share calculation code

grep -rn --include="*.rs" -iE "shares|total_supply|mint_to|share_price|per_share" programs/
  • Record: The exact formula used for deposit→shares conversion

Step 2: Check for virtual offset (inflation protection)

# Look for a minimum initial deposit, virtual shares, or dead shares pattern
grep -rn --include="*.rs" -iE "virtual|dead_shares|minimum.*deposit|min_deposit\|MINIMUM" programs/
  • ✅ PASS: Virtual offset (e.g., 1000 virtual shares) or minimum first deposit that prevents the attack
  • ❌ FAIL: No protection — shares = deposit * total_shares / total_assets with no minimum

Step 3: Verify division order

# In the share calculation, multiplication must come BEFORE division
# Correct: shares = (deposit * total_shares) / total_assets
# Wrong: shares = deposit * (total_shares / total_assets) — precision loss
  • Read the actual calculation code and verify mul-before-div
  • ✅ PASS: Multiplication before division with checked_mul then checked_div
  • ❌ FAIL: Division happens before multiplication

Step 4: Check for rounding direction

# Deposits should round DOWN (fewer shares to depositor — protocol favored)
# Withdrawals should round DOWN (less assets to withdrawer — protocol favored)
  • ✅ PASS: Rounding consistently favors the vault/protocol
  • ❌ FAIL: Rounding can go against the vault (attacker extracts dust)

Step 5: Test edge case — deposit with total_shares = 0

grep -rn --include="*.rs" -A20 "total.*shares.*==.*0\|total_supply.*==.*0\|if.*first" programs/
  • ✅ PASS: First deposit has special handling (e.g., 1:1 ratio, minimum deposit, dead shares minted)
  • ❌ FAIL: First deposit follows same formula as subsequent (vulnerable to inflation)

Overall verdict:

  • ✅: Virtual offset, correct rounding, mul-before-div, first deposit protection
  • ⚠️: Some protections but missing virtual offset or minimum
  • ❌: No first depositor protection AND rounding can be exploited

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