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-vectors146-parent-substitution-authority-bypass.md

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

146 — Parent-Substitution Authority Bypass (Root-Anchor Chain)

Severity: 9 when the child holds or prices user funds | Real: Solend "malicious lending market" (19 Aug 2021): reserve parameters on the real USDC/SOL/ETH/BTC reserves were changed through an attacker-owned market (liquidation threshold 80→1, liquidation bonus 5→90, min borrow rate 0→250); Solend's own bot liquidated, no user funds lost, about $2M at risk. Cashio ($52M, 2022): an unanchored collateral/mint validation chain.

The signer check is present and correct, but anchored to an account the attacker chose: signer → P.authority is meaningful only if the mutated child C belongs to P (C.parent == P.key()), and P to its own parent, up to a trusted root. Chains of comparisons only among passed-in accounts (A.key() == B.field, B.key() == C.field) prove internal consistency, not authority; at least one link must compare against a trusted program-owned account field or a hard-coded constant. Common in multi-tenant programs: markets/reserves, pools/positions, DAOs/proposals, managers/strategies, games/rounds. (For Solend, the exact missing comparison is reconstructed, not quoted from the incident report.)

Cross-ref: AC-057, AV-020/AC-003 (this vector extends them with the chain walk), FULL-AUDIT Step 1.5 P2.

Verification Procedure

Step 1: Handlers that authorise through another account's field

rg -n 'has_one\s*=\s*(owner|authority|admin)' programs/
rg -n '(market|pool|vault|config|dao|realm|group)\.(owner|authority|admin)\s*==' programs/
rg -n 'has_one\s*=\s*(lending_market|market|pool|vault|config|group|realm)' programs/

Step 2: Walk the chain for every mutated child

  • ✅ PASS: each link is bound — has_one = parent, or seeds containing parent.key() — up to a PDA-derived/program-owned root or a constant
  • ❌ FAIL: the child is mutated under the authority of a parent it is not bound to; the chain closes only among passed-in accounts
// VULNERABLE: signer owns *a* market, not necessarily this reserve's market
#[derive(Accounts)]
pub struct UpdateReserveConfig<'info> {
    #[account(mut)] pub reserve: Account<'info, Reserve>,
    #[account(has_one = owner)] pub lending_market: Account<'info, LendingMarket>, // attacker's market
    pub owner: Signer<'info>,
}
// FIXED: bind child to parent, then parent to signer
#[derive(Accounts)]
pub struct UpdateReserveConfig<'info> {
    #[account(mut, has_one = lending_market @ ErrorCode::WrongMarket)] pub reserve: Account<'info, Reserve>,
    #[account(has_one = owner @ ErrorCode::NotOwner)] pub lending_market: Account<'info, LendingMarket>,
    pub owner: Signer<'info>,
}

Overall verdict:

  • ✅: every privileged mutation is anchored to a trusted root
  • ❌: any privileged instruction accepts an attacker-created parent

Sources: sannykim/solsec → Solend incident report and reconstruction [paraphrased, cited: https://docs.google.com/document/d/1-WoQwT1QrPEX-r4N-fDamRQ50LM8DsdsOyq1iTabS3Q , https://hackmd.io/54qwl3oeT4CYuREUgxQ2zQ]; qedgen/solana-skills skills/qedgen-auditor/references/category-catalog.md field_chain_missing_root_anchor (MIT, Copyright (c) 2025 QEDGen).

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