From tenequm-skills
Audit Solana programs (Anchor or native Rust) for security vulnerabilities. Use when reviewing smart contract security, finding exploits, analyzing attack vectors, performing security assessments, or when explicitly asked to audit, review security, check for bugs, or find vulnerabilities in Solana programs.
npx claudepluginhub tenequm/skills --plugin gh-cliThis skill uses the workspace's default tool permissions.
Systematic security review framework for Solana programs, supporting both Anchor and native Rust implementations.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Checks Next.js compilation errors using a running Turbopack dev server after code edits. Fixes actionable issues before reporting complete. Replaces `next build`.
Systematic security review framework for Solana programs, supporting both Anchor and native Rust implementations.
Follow this systematic 5-step process for comprehensive security audits:
Understand the program's context and structure:
use anchor_lang::prelude::*)Cargo.toml for compatibility and known issuesFor each instruction, perform security checks in this order:
checked_* methodsโ See references/security-checklists.md for detailed checklists
Scan for common vulnerability patterns:
โ See references/vulnerability-patterns.md for code examples and exploit scenarios
Evaluate overall design quality:
Provide findings using this structure:
Severity Levels:
Finding Format:
## ๐ด [CRITICAL] Title
**Location:** `programs/vault/src/lib.rs:45-52`
**Issue:**
Brief description of the vulnerability
**Vulnerable Code:**
```rust
// Show the problematic code
Exploit Scenario: Step-by-step explanation of how this can be exploited
Recommendation:
// Show the secure alternative
References:
**Report Summary:**
- Total findings by severity
- Critical issues first (prioritize by risk)
- Quick wins (easy fixes with high impact)
- Recommendations for testing improvements
## Quick Reference
### Essential Checks (Every Instruction)
**Anchor:**
```rust
// โ
Account validation with constraints
#[derive(Accounts)]
pub struct SecureInstruction<'info> {
#[account(
mut,
has_one = authority, // Relationship check
seeds = [b"vault", user.key().as_ref()],
bump, // Canonical bump
)]
pub vault: Account<'info, Vault>,
pub authority: Signer<'info>, // Signer required
pub token_program: Program<'info, Token>, // Program validation
}
// โ
Checked arithmetic
let total = balance.checked_add(amount)
.ok_or(ErrorCode::Overflow)?;
Native Rust:
// โ
Manual account validation
if !authority.is_signer {
return Err(ProgramError::MissingRequiredSignature);
}
if vault.owner != program_id {
return Err(ProgramError::IllegalOwner);
}
// โ
Checked arithmetic
let total = balance.checked_add(amount)
.ok_or(ProgramError::ArithmeticOverflow)?;
โ Never Do:
saturating_* arithmetic methods (hide errors)unwrap() or expect() in production codeinit_if_needed without additional checksโ Always Do:
checked_* arithmetic (checked_add, checked_sub, etc.)ok_or(error)? for Option unwrappinginit with proper validationSigner<'info> or is_signer checksProgram<'info, T> for CPI program validationโ See references/anchor-security.md for:
CpiContextโ See references/native-security.md for:
InitSpace derive for automatic space calculationโ See references/security-fundamentals.md for:
โ See references/vulnerability-patterns.md for:
Each vulnerability includes:
โ See references/security-checklists.md for:
โ See references/caveats.md for:
โ See references/resources.md for:
Always verify these critical security properties:
Can an attacker substitute accounts?
Can arithmetic overflow or underflow?
Are all accounts properly validated?
Can the program be drained?
What happens in edge cases?
Are external dependencies safe?
Beyond code review, validate security through testing:
In Solana's account model, attackers can pass arbitrary accounts to any instruction.
Security requires explicitly validating:
There are no implicit guarantees. Validate everything, trust nothing.