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-vectors165-residual-delegate-approval.md

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

165 — Residual SPL Delegate Approval on a Program-Owned Token Account

Severity: 7 (8 if the delegate can be driven by anyone, e.g. through a permissionless instruction on the delegate program) | Real: approve/consume mismatch pattern (approves out + fee, consumes out − fee)

A program approves a delegate on a PDA-owned token account so an external program (aggregator, lending CPI, legacy integration) can pull tokens. If the callee pulls less than approved, delegated_amount stays above zero after the instruction; the delegate — or anyone who can make the delegate act — spends the remainder later. (The token program clears the delegate automatically only when delegated_amount reaches exactly 0.) CPI-026/027 check approve/revoke correctness, not the post-CPI residual. Note SPL approve replaces the delegated amount (CPI-038).

Cross-ref: CPI-037, CPI-041, CPI-026/027.

Verification Procedure
rg -n 'token(_interface)?::approve(_checked)?\(' programs/
rg -n 'token(_interface)?::revoke\(' programs/
rg -n 'delegated_amount|delegate\.is_none' programs/
  • ✅ PASS: approve exactly what is consumed, revoke after the CPI, reload() and assert delegate.is_none() && delegated_amount == 0; or move the exact amount into a per-operation account. PDA-signer CPIs (instead of approvals) only to a pinned, trusted program — lending the PDA's signer privilege to a third party lets it act as the PDA, for the whole CPI, over every PDA-controlled account passed into that CPI
  • ❌ FAIL: an approval can outlive the instruction
// VULNERABLE
token::approve(ctx.accounts.approve_ctx().with_signer(signer), amount + fee)?;
external::swap(ctx.accounts.swap_ctx(), amount - fee)?;            // 2·fee allowance remains

// FIXED
token::approve(ctx.accounts.approve_ctx().with_signer(signer), amount)?;
external::swap(ctx.accounts.swap_ctx(), amount)?;
token::revoke(ctx.accounts.revoke_ctx().with_signer(signer))?;
ctx.accounts.vault.reload()?;
require!(ctx.accounts.vault.delegate.is_none() && ctx.accounts.vault.delegated_amount == 0, ErrorCode::ResidualDelegate);

Overall verdict:

  • ✅: no residual allowance survives
  • ❌: one does

Sources: pashov/skills solidity-auditor/references/hacking-agents/execution-trace-agent.md and solidity-auditor/references/hacking-agents/numerical-gap-agent.md (MIT, Copyright (c) 2024 AI Skills Contributors), Solana-ported; the "use invoke_signed instead" advice removed.

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