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.

checklists22-token-2022.md

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

22 — Token-2022 Checklist (integrator and transfer-hook author)

Domain: On-chain Solana Program Severity if missed: HIGH References: references/methodologies/token-2022.md; Neodyme Token-2022 article and audit (cited, paraphrased); solana-foundation/solana-dev-skill (MIT); beriktassuly/solana-audit-skill (MIT) Load when: token_2022 · spl_token_2022 · TokenInterface · InterfaceAccount · transfer_hook · spl_transfer_hook_interface Complements (does not repeat) T1–T12 in token-2022.md and EXT-012..015 in checklist 04.

Every item below is a single verification step. Mark each [PASS], [FAIL-{severity}], [PARTIAL], or [N/A].


22.1 — Policy & combinations

  • TK-001: Every extension that can affect value, authority, liveness, display or close behaviour has exactly one policy — supported / rejected / residual risk — with evidence and residual-risk columns (token-2022.md §13).
  • TK-002: Fee + hook on the same transfer is handled (delta accounting and hook rules); no code assumes TransferHook × TransferFee is impossible (token-2022.md §3).
  • TK-003: "Pay exactly X net" paths use the inverse-fee helper (calculate_inverse_epoch_fee) and transfer_checked_with_fee as an assertion, not calculate_fee(x) added to x.
  • TK-004: Fees are computed at use time from get_epoch_fee(Clock::get()?.epoch); no cached bps, no direct read of newer_transfer_fee; quote-to-settle paths carry slippage bounds.

22.2 — CPI Guard

  • TK-005: User-funded pulls work for users with CPI Guard enabled: the user signs a top-level Approve to a program PDA, the program transfers as delegate and verifies the delta; no flow forwards the owner's signature into a Token-2022 transfer/burn CPI.
  • TK-006: Protocol vaults use ImmutableOwner; no requirement relies on CPI Guard on PDA-owned vaults (a PDA cannot enable it).
  • TK-007: No security argument relies on CPI Guard against a Token-2022 build older than the ND-ANZ-LO-01 fix (an owner that approved itself as delegate, Approve(delegate = owner), bypassed the guard), e.g. vendored binaries in test validators or forks; current Token-2022 rejects owner-signed transfers in CPI even when the owner is also the delegate or permanent delegate. <!-- verified: token-2022 HEAD program/src/processor.rs (CpiGuardTransferBlocked when the authority is the owner, lock_cpi and in_cpi) -->

22.3 — Close paths & payouts

  • TK-008: Before closing a token account of a fee mint, withheld fees are harvested (anchor_spl::token_2022_extensions::harvest_withheld_tokens_to_mint or the spl_token_2022_interface::extension::transfer_fee::instruction::harvest_withheld_tokens_to_mint builder, also reachable as spl_token_2022::extension::transfer_fee::instruction::… in the program crate), or the close is best-effort / a separate crank (KV-168). <!-- verified: anchor v1.2.1 spl/src/token_2022_extensions/{mod.rs,transfer_fee.rs}; token-2022 HEAD interface/src/extension/transfer_fee/mod.rs `TransferFeeAmount::closable` -->
  • TK-009: Close paths handle non-zero ConfidentialTransferAccount pending/available balances and ConfidentialTransferFeeAmount (each has a closable() check); the confidential withheld-fee harvest to the mint can be turned off by the confidential fee authority (DisableHarvestToMint sets harvest_to_mint_enabled = false, and the harvest then fails with HarvestToMintDisabled), so a close path must not depend on that harvest. <!-- verified: token-2022 HEAD program/src/extension/confidential_transfer_fee/processor.rs -->
  • TK-010: Closes sweep the live balance after reload() with transfer_checked (not a recorded amount, not unchecked transfer, which Token-2022 rejects with MintRequiredForTransfer whenever the source carries TransferFeeAmount, TransferHookAccount or PausableAccount). <!-- verified: token-2022 HEAD program/src/processor.rs process_transfer, no-mint branch -->
  • TK-011: Payouts to user accounts are pull-based; where push is unavoidable, a Memo CPI immediately precedes each transfer to a MemoTransfer destination (same stack height).
  • TK-012: No batch distribution/settlement/liquidation pushes to N recipient-controlled accounts in one instruction (KV-169).

22.4 — Mint lifecycle & identity

  • TK-013: Mints with MintCloseAuthority are refused, or every use checks account-vs-mint extension consistency and the vault is program-created at a PDA (KV-166).
  • TK-014: A mint-registry fingerprint (if used) hashes u16::from(ext) values (ExtensionType is #[repr(u16)] with IntoPrimitive) excluding TokenMetadata/TokenGroup/TokenGroupMember, includes rotatable authority keys (hook program id, permanent delegate, freeze authority), and is re-validated on every deposit/swap/transfer path.
  • TK-015: The TransferHook.program_id is re-checked against the allowlist on every transfer path, not only at registration (the hook authority can swap it).
  • TK-016: A later DefaultAccountState::Update to Frozen (freeze authority) is handled: vault/recipient accounts created afterwards start frozen, surfaced as a clean error (T5).
  • TK-017: Token account vs mint vs multisig are classified by typed unpack after the owner check, never by length (165/82/355; a T22 length that would equal 355 is padded by 2 bytes, size_of::<ExtensionType>()); PodStateWithExtensions/StateWithExtensions unpack errors are handled, not unwrap()ed (error clarity).
  • TK-018: Protocols that tolerate permanent-delegate mints reconcile stored totals with balances and handle vault.amount < recorded_total and == 0 without division by zero, underflow or socialising one user's loss onto others.
  • TK-019: Confidential receive paths tolerate MaximumPendingBalanceCreditCounterExceeded; owners/keepers apply pending balances on a schedule; settlement does not require pushing confidential credits into adversary-saturable accounts. <!-- verified: token-2022 HEAD interface/src/error.rs `MaximumPendingBalanceCreditCounterExceeded` -->
  • TK-020: Automated apply-then-withdraw confidential flows batch or delay so single credits are not linkable, or the privacy limitation is documented.
  • TK-021: Pushes tolerate recipients that disabled confidential or non-confidential credits (DisableConfidentialCredits / DisableNonConfidentialCredits).
  • TK-022: Accounts lacking an account extension the current mint requires (TransferHookAccount, TransferFeeAmount, PausableAccount) are rejected before value moves: an orphan source can use the mint-less Transfer instruction to skip fee, hook and pause, because Token-2022 decides whether the mint is required from the source account's extensions (KV-166).
  • TK-023: For Pausable mints, pause guarantees are not assumed to cover pre-existing accounts without PausableAccount.
  • TK-024: The negative-test set exists: wrong token program variant; unsupported extension mix; fee mint with net < requested; hook mint with an unapproved hook; memo-required destination without memo; default-frozen source/destination; permanent delegate present; close with withheld fees present — each proving rejection before state mutation.

22.5 — If the audited program IS a transfer hook (KV-167)

  • HOOK-01: The mint is one the hook serves, validated against config in a PDA keyed by the mint.
  • HOOK-02: Source and destination have TransferHookAccount.transferring == true, read via StateWithExtensions::<Account>::unpack + get_extension::<TransferHookAccount>(), and are owned by Token-2022.
  • HOOK-03: source.mint == destination.mint == mint.
  • HOOK-04 (optional, trade-off): the top-level instruction is Token-2022 (get_instruction_relative(0, ..), sysvar address-pinned) — rejects all composable transfers; documented if used.
  • HOOK-05: The extra-account-metas PDA is [b"extra-account-metas", mint] under the hook program; only the intended authority can initialise/update it; every trusted extra account is re-validated (owner, seeds, discriminator), never trusted by position.
  • HOOK-06: No privilege assumptions: the four core accounts arrive read-only and non-signer; extras keep the is_signer/is_writable set in their ExtraAccountMeta; a hook that always errors bricks the mint, and the hook authority can swap programs.

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