/auditsentry:solana-anchorfrom auditsentry
Detects critical Solana/Anchor (Rust) vulnerabilities: missing signer/owner checks, account confusion, type cosplay, PDA seed collisions, CPI to unverified programs, lamport drains, sysvar spoofing, and missing constraints. Activates on any .rs file with Anchor imports or macros.
Ships in auditsentry. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
.rs file importing anchor_lang (use anchor_lang::prelude::*)#[program], #[derive(Accounts)], #[account], #[instruction(...)]Signer<'info>, Account<'info, T>, AccountInfo<'info>, UncheckedAccount, Program<'info, T>, Sysvar<'info, T>seeds = [...], bump, find_program_address, create_program_addressCpiContext, invoke, invoke_signed, *_cpiSolana has no implicit caller. Every authority, ownership, and identity invariant must be asserted explicitly in the account struct or handler.
#[derive(Accounts)]
pub struct Withdraw<'info> {
pub authority: AccountInfo<'info>, // ← not Signer; nobody proves they're authority
#[account(mut)]
pub vault: Account<'info, Vault>,
}
Signal: an "authority"/"owner"/"admin" account typed AccountInfo/UncheckedAccount instead of Signer<'info>, or a handler reading ctx.accounts.x without checking x.is_signer. Anyone passes the real authority's pubkey without their signature.
let data = ctx.accounts.state.to_account_info();
let state = State::try_from_slice(&data.data.borrow())?; // ← no owner check
Signal: deserializing from a raw AccountInfo/UncheckedAccount without verifying account.owner == program_id, or using Account<T> for data but not constraining which account. An attacker passes a fake account they own with crafted bytes. Account<'info, T> checks owner+discriminator; raw AccountInfo checks nothing.
let user: UserAccount = UserAccount::try_from_slice(&info.data.borrow())?; // ← any 8-byte
Signal: try_from_slice / try_deserialize_unchecked on raw data, bypassing the Anchor 8-byte discriminator. A different account type with the same layout (e.g. Config passed where User is expected) is accepted. Use Account<'info, T> so Anchor enforces the discriminator.
let (pda, _bump) = Pubkey::create_program_address(
&[b"vault", user.key().as_ref(), &[user_supplied_bump]], // ← attacker bump
program_id,
)?;
Signal: create_program_address with a caller-supplied bump (multiple valid PDAs → forgeable accounts), bumps not stored/re-checked against the canonical one, or seeds that omit a discriminator so ["vault", x] collides with ["vault", x] of another domain. Use find_program_address (canonical bump) or Anchor seeds+bump and persist bump.
#[derive(Accounts)]
pub struct Update<'info> {
#[account(mut)] // ← no has_one = authority
pub config: Account<'info, Config>,
pub authority: Signer<'info>, // signs, but is never tied to config.authority
}
Signal: a Signer that's never bound to the data account it should control — no #[account(has_one = authority)] or #[account(constraint = config.authority == authority.key())]. Any signer updates any config. Same for mint, owner, vault relationships.
let cpi = CpiContext::new(ctx.accounts.token_program.to_account_info(), ...);
token::transfer(cpi, amount)?; // ← token_program is an unconstrained AccountInfo
Signal: CpiContext::new whose program account isn't constrained to the expected Program<'info, Token> / known program id, or invoke/invoke_signed to a caller-supplied program. Attacker passes a malicious program at the token_program slot. Type it Program<'info, Token> or assert the key.
**ctx.accounts.dest.lamports.borrow_mut() += account.lamports();
**account.lamports.borrow_mut() = 0; // ← manual close, no discriminator zeroing
Signal: manual lamport zeroing without wiping the discriminator/data, or #[account(close = ...)] whose data the attacker can re-fund in the same tx (revival attack) before it's GC'd. Use Anchor close = recipient (it zeroes the discriminator) and don't reuse closed accounts in the same instruction.
pub clock: AccountInfo<'info>, // ← passed as raw account, not Sysvar
let now = Clock::from_account_info(&ctx.accounts.clock)?.unix_timestamp;
Signal: Clock/Rent/Instructions sysvars typed as AccountInfo/UncheckedAccount rather than Sysvar<'info, Clock> or fetched via Clock::get(). An attacker substitutes a fake sysvar account with controlled time/data.
/// CHECK: comment present but the account is then trusted for transfers
pub recipient: UncheckedAccount<'info>,
Signal: UncheckedAccount/AccountInfo (or a /// CHECK: with no real validation) that's subsequently used as a transfer destination, authority, or data source. The CHECK comment silences Anchor but doesn't add a constraint.
| Pattern | Severity | Notes |
|---|---|---|
Authority as AccountInfo, no signer proof | Critical | Impersonate any authority |
| Deserialize raw account, no owner check | Critical | Fake-account substitution |
| Type cosplay (no discriminator) | High | Wrong account type accepted |
| Caller-supplied / non-canonical PDA bump or seed collision | High | Forge PDA-owned accounts |
Missing has_one/constraint linking signer↔data | High | Any signer mutates any record |
| CPI to unconstrained program account | High | Malicious program at slot |
| Manual close / revivable closed account | High | Lamport drain / reuse |
Sysvar passed as AccountInfo | Medium | Spoofed clock/rent |
UncheckedAccount used for value flow | Medium | Depends on later checks |
Signer<'info> and assert their relationship with #[account(has_one = authority)] or constraint =.Account<'info, T> (not raw AccountInfo) so Anchor enforces owner == program_id AND the 8-byte discriminator; never try_from_slice/try_deserialize_unchecked on untrusted accounts.seeds = [...] + bump (or find_program_address), store the bump, include a domain discriminant in seeds to prevent collisions.Program<'info, Token>/known ids; validate any account passed to invoke/invoke_signed.#[account(close = recipient)] so the discriminator is zeroed; don't reuse a closed account within the instruction.Clock::get() or Sysvar<'info, Clock>, never a raw account./// CHECK: with an actual key/owner constraint, not just a comment.AccountInfo/UncheckedAccount with a real #[account(address = KNOWN_PUBKEY)] or in-handler key assertion is validated — don't flag it as unchecked.Account<'info, T> already enforces owner + discriminator; type-cosplay and owner-check findings apply to RAW AccountInfo/try_from_slice paths only.Signer that legitimately needs no data binding (e.g. a fee payer that only pays rent) doesn't need has_one.init/init_if_needed accounts set their own owner to the program — owner-check findings don't apply at init.Added program-derived address (PDA) validation for Anchor programs. The skill now detects:
seeds constraint on PDA accounts initialized via CPIinit and subsequent mut constraintshas_one constraints on associated token accounts// VULNERABLE: Missing seeds constraint on PDA init
#[derive(Accounts)]
pub struct InitializePool {
#[account(init, payer = admin, space = 8 + Pool::SIZE)]
pub pool: Account<'info, Pool>, // ❌ Missing PDA seed derivation
pub admin: Signer<'info>,
}
The skill verifies Anchor IDL account constraints against actual on-chain validation and flags mismatches that could allow fake PDA injection attacks.
What SKILL.md sets; muted values are Claude Code's defaults
45 skills in this plugin
/access-controlDetect missing or incorrect access control — missing modifiers, wrong role checks, privileged function exposure, public initializers, and role-escalation paths. Activate on any function that mutates state, transfers funds, mints tokens, sets admin parameters, upgrades implementations, or pauses/unpauses./approval-issuesDetect ERC-20 approval pitfalls — approve race (front-run), missing safeApprove, infinite approvals, approval-without-revoke, Permit2 misuse, max-approval to untrusted contracts. Activate on `approve`, `safeApprove`, `permit`, `forceApprove`, `Permit2`, `IERC20.allowance`./caching-and-incrementalAlways-on meta-skill — cache audit results per file by content hash so unchanged files aren't re-analyzed on subsequent runs. Activate on every /audit, /quick-scan, /audit-changes invocation./centralization-riskDetect centralization and trust-assumption risks — admin powers, single-key risk, missing timelocks, upgrade authority, treasury keys, pause permanence, blacklisting authority, oracle authority. Activate on `onlyOwner`, `onlyRole`, `AccessControl`, upgrade authorizations, pause/unpause functions, mint/burn caps, treasury/fee setters./confidence-scoringAlways-on meta-skill — for every finding produced, attach a confidence level (HIGH/MEDIUM/LOW) and a reasoning trace. Activate on every /audit, /audit-deep, /audit-changes, /audit-live, /quick-scan invocation./cosmwasmDetect bug classes specific to CosmWasm (Rust) contracts — missing info.sender authorization in execute handlers, unbounded map iteration → gas/DoS, reply/submessage reply_id confusion, migrate admin backdoors, addr_validate vs raw string addresses, unchecked info.funds, Uint128 overflow, query reentrancy, and migration/version state. Activate on any `.rs` file with `use cosmwasm_std`, `#[entry_point]`, `ExecuteMsg`, `InstantiateMsg`, `QueryMsg`, `cw_storage_plus`, or `DepsMut`.npx claudepluginhub iktok90-design/ai-smart-contract-auditor --plugin auditsentryOther plugins' skills for the same job