0x-shashi/web3-audit-skills/solana-scanner
Claude Code and agent skill by 0x-shashi/web3-audit-skills
- community
Checking that the SKILL.md file is still in the repository.
Use when auditing Solana programs for security vulnerabilities, reviewing Anchor or Pinocchio/native Rust smart contracts, checking CPI safety, PDA validation, account ownership, signer verification, or Token-2022 security.
Install
npx vskill@latest install 0x-shashi/web3-audit-skills/solana-scannerSKILL.md
The same SKILL.md was published earlier as 0x-shashi/web3-audit-skills/solana-scanner.
Solana Scanner Skill
Purpose
Analyze Solana programs (Rust/Anchor) for security vulnerabilities specific to the Solana runtime model. Solana's account-based execution model, where programs are stateless and all state is passed via accounts, creates a fundamentally different attack surface from EVM chains.
Core Principle
An attacker controls every account, argument, ordering, and CPI call-graph passed to your program. Your on-chain code must prove each input is legitimate before touching state or funds.
Solana Security Model
| Property | Solana | EVM | |
|---|---|---|---|
| Execution model | Programs receive accounts as input | Contracts own their storage | |
| State ownership | Account owner (program ID) controls data | Contract controls its own storage | |
| Caller identity | Signer flag on accounts | msg.sender | |
| Cross-program calls | CPI — accounts passed through | Internal calls share storage | |
| Math safety | Overflow wraps in release mode | Solidity 0.8+ reverts on overflow | |
| Account validation | Manual (native) or declarative (Anchor) | Automatic via msg.sender | |
| Upgrades | Program authority can upgrade any time | Proxy patterns required | |
| Rent | Accounts must maintain minimum SOL balance | No rent (storage is permanent) |
Detection Capabilities
Critical — Direct Fund Loss
| Vulnerability | Description | Detection Signal | |
|---|---|---|---|
| Missing signer check | Privileged instruction lacks signer validation | AccountInfo without is_signer check | |
| Missing owner check | Program accepts accounts owned by other programs | No owner == program_id validation | |
| Arbitrary CPI | Cross-program invocation to user-controlled program ID | invoke() with unchecked program_id | |
| PDA seed manipulation | PDA derived with controllable seeds | Seeds include user-controlled data without validation | |
| Account data overwrite | Writing data to wrong account | Missing discriminator / account type check |
High — Significant Impact
| Vulnerability | Description | Detection Signal | |
|---|---|---|---|
| Integer overflow (release) | Wrapping arithmetic in release builds | Math ops without checked_* or Anchor require! | |
| Account closing revival | Closed account can be revived in same tx | Close without zeroing data + relying on zero lamports | |
| Duplicate account injection | Same account passed for two different parameters | No uniqueness check between accounts | |
| Type confusion | Account deserialized as wrong type | Missing discriminator validation | |
| CPI privilege escalation | CPI inherits signer privileges incorrectly | invoke_signed() with wrong seeds |
Medium — Conditional Impact
| Vulnerability | Description | Detection Signal | |
|---|---|---|---|
| PDA bump seed guessing | Not storing/reusing canonical bump | find_program_address in instruction logic | |
| Missing rent exemption | Account may be garbage collected | No rent-exempt check after creation | |
| Unchecked account size | Account realloc without bounds | realloc() without size validation | |
| Clock dependency | Using Clock::get() for security-sensitive logic | Validator can influence timestamp slightly | |
| Token account validation | SPL Token account not validated for mint/owner | Missing token::mint or token::authority check |
Key Audit Patterns
Vulnerability Categories with Prevention Code
Each category shows the risk, an attack example, and prevention for both Anchor and Pinocchio/native Rust.
1. Missing Owner Checks
Risk: Attacker substitutes a fake account owned by their own program with crafted data.
2. Missing Signer Checks
Risk: Anyone can call privileged instructions (withdraw, admin config).
3. Arbitrary CPI
Risk: Attacker passes a malicious program ID, redirecting CPI to their program.
4. Reinitialization
Risk: Attacker re-calls initialize to overwrite authority/settings.
5. PDA Sharing
Risk: Multiple users share one PDA → state confusion, fund theft.
6. Type Cosplay
Risk: Attacker passes account of type A where type B is expected (same size).
7. Duplicate Mutable Accounts
Risk: Same account passed as both source and destination → double-counting.
8. Account Revival (Closing)
Risk: Closed account (0 lamports) data remains in tx — later instruction reads stale state.
9. Data Matching
Risk: Token account's mint or authority doesn't match expected values.
Account Validation Matrix
Every instruction must validate EVERY account it accesses. Use this matrix:
| Check | Native Solana | Anchor | |
|---|---|---|---|
| Is signer? | account.is_signer | Signer<'info> | |
| Is writable? | account.is_writable | #[account(mut)] | |
| Correct owner? | account.owner == &program_id | Account<'info, T> (automatic) | |
| Correct PDA? | Pubkey::find_program_address() | #[account(seeds = [...], bump)] | |
| Correct data type? | Check discriminator manually | Account<'info, T> (automatic) | |
| Belongs to user? | Manual field comparison | #[account(has_one = owner)] | |
| Not closed? | Check lamports > 0 and data | Account<'info, T> (checks discriminator) | |
| Unique? | Compare pubkeys between params | Manual (Anchor doesn't auto-check) |
Solana-Specific Attack Vectors
- Account Confusion Attack: Passing a token account where a mint account is expected (or vice versa)
- Reinitialization Attack: Calling
initializeon already-initialized account - Closing Account Revival: Closing an account (zero lamports) but data remains readable in same tx
- CPI Re-signer Attack: Exploiting that CPI can sign with PDA seeds the caller controls
- Remaining Accounts Abuse: Exploiting unchecked accounts in
ctx.remaining_accounts - Flashback Attack: Solana transactions can include multiple instructions — attacker can create and exploit account state in same tx
Program-Side Security Checklist
Account Validation (7 checks)
- [ ] Every account has an owner check (native) or uses
Account<'info, T>(Anchor) - [ ] Every privileged account has a signer check
- [ ] PDAs are derived with sufficient unique seeds (no PDA sharing)
- [ ] All accounts have discriminator validation (type cosplay prevention)
- [ ] Semantically distinct accounts are compared for uniqueness
- [ ]
has_one/ manual field comparison for data matching (mint, authority) - [ ] Accounts in
remaining_accountsare validated before use
CPI Safety (3 checks)
- [ ] CPI target is a known program (
Program<'info, T>or key comparison) - [ ]
invoke_signedseeds are deterministic and cannot be replayed - [ ] CPI return data is validated, not blindly trusted
Arithmetic (3 checks)
- [ ] All math uses
checked_*operations oroverflow-checks = truein Cargo.toml - [ ] Token amounts validated against actual balances before transfer
- [ ] Fee/reward calculations handle rounding and zero-value edge cases
State Lifecycle (4 checks)
- [ ]
initis used instead ofinit_if_needed(prevents front-running) - [ ] Closed accounts are zeroed + poisoned (discriminator = 0xFF)
- [ ] Upgrade authority is verified or program is immutable in production
- [ ] Account realloc operations check size bounds
Client-Side Security Checklist
- [ ] Correct cluster (mainnet vs devnet) — program IDs differ
- [ ] Transactions are simulated before sending to catch errors early
- [ ]
getLatestBlockhashuses confirmed or finalized commitment - [ ] Transaction confirmation waits for sufficient commitment level
- [ ] Token-2022 extensions (transfer hooks, transfer fees) are handled
- [ ] Lookup tables / versioned transactions are used for large account sets
- [ ] Priority fees are set appropriately for congested network conditions
Build & IDL Integrity Checklist
Supply-chain and deployment verification — catches mismatches between audited source and deployed program.
- [ ] On-chain program matches audited source — verify with
solana program dump+ local rebuild - [ ] IDL matches on-chain behavior — generated IDL (Anchor/Codama) reflects actual instruction layouts
- [ ] No hand-written Borsh layouts for programs the team owns — use IDL/codegen pipeline (hand-written layouts risk serialization mismatches → type confusion)
- [ ] No hand-written IDLs — generate from source via
anchor buildor Shank macros - [ ] Codegen outputs checked into git for deterministic builds, or generated in CI with pinned versions
- [ ] Anchor version pinned in
Anchor.toml— different Anchor versions produce different discriminators - [ ] Solana CLI + Anchor versions aligned across dev, CI, and audit environments
- [ ] Program upgrade authority is multisig or governance (not a single EOA) for mainnet deployments
- [ ] If upgradeable, upgrade timelock exists to allow users to exit before code changes
Security Review Questions
When reviewing a Solana program, systematically ask:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 98 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/solana-scanner/SKILL.md
Popularity
- Repository stars
- 62
- Repository forks
- 10
- 7-day trend score
- 19
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 18 Mar 2026, 8 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/0x-shashi/web3-audit-skills/solana-scanner)