Solana Anchor (Rust) Smart Contract Security Audit & Exploit Guard
Audit Solana programs for catastrophic exploits. Enforces Anchor constraints (`has_one`, `signer`, `mut`), validated PDA derivation bumps, and safe SPL Token CPI cross-program invocations.
Parametric Customizer & Compiler Live Tool
Adjust the variables below. The prompt code and API payload update dynamically in real time.
Core on-chain protocol architecture.
Specific smart contract attack vector.
Solana token program implementation.
Code-level security guardrails.
You are a Principal Web3 Security Researcher and Senior Solana Program Auditor specializing in the Anchor framework and high-TVL on-chain protocols. OBJECTIVE: Perform an exhaustive security vulnerability audit and generate hardened Rust code for: Program Module: Automated Market Maker (AMM) constant product liquidity pool with dynamic swap fees Security Vulnerability Vector: Cross-Program Invocation (CPI) arbitrary program substitution and fake token mint injection Token Standard: Token-2022 program with transfer fee extension and confidential transfer support Defensive Invariant: Anchor declarative constraints: #[account(mut, has_one = authority, seeds = [...], bump = vault.bump)] STRICT SOLANA AUDITING RULES: 1. Missing Signer & Ownership Checks: Verify that every account mutating state has `#[account(signer)]` and matches expected program ownership. 2. PDA Bump & Seed Validation: Never trust client-supplied bumps; enforce canonical bump derivation via `find_program_address`. 3. Account Confused Deputy & Reloads: Ensure mutable accounts reloaded after CPI calls maintain state integrity. 4. Checked Arithmetic: Use `checked_add`, `checked_sub`, or `checked_mul` to eliminate integer overflow/underflow exploits. 5. Closing Accounts Rent Exemption: Protect against revive-after-close exploits by zeroing out account discriminators upon close.
Catch mission-critical Solana smart contract vulnerabilities in Cursor.
Leonardo Phoenix & Flux: Generate photorealistic studio assets with 150 daily free credits. Zero setup required.
πΈ Real Sample Outputs & Verified Results
Visual evidence and benchmark responses generated using this exact prompt formula.
π¬ Prompt Engineering Anatomy
Why this prompt consistently delivers high-tier results: technical parameter breakdown.
Canonical PDA Bump Verification Accepting arbitrary bumps from user transactions allows attackers to find non-canonical bumps that pass signature verification on unexpected seed collisions.
Arbitrary Program Substitution Guard If a CPI invokes a `token_program` account passed in by the client without verifying its public key equals `spl_token::ID` or `spl_token_2022::ID`, an attacker can pass a malicious program.
π¬ Frequently Asked Questions
Troubleshooting common edge cases, model incompatibilities, and best practices.
Is this prompt tuned for Anchor 0.30?
Yes! It enforces Anchor 0.30 syntax including `InterfaceAccount` and `TokenInterface` for seamless Token-2022 compatibility.
Can Cursor AI audit entire Solana repositories with this prompt?
Yes, drop this prompt into Cursor's Composer or Claude 3.7 with codebase indexing to audit every `#[derive(Accounts)]` struct across your project.
Cursor AI & Claude 3.5 Sonnet Pro Bundle
Supercharge your workflow with instant codebase indexing, multi-file edits, and automated system rules.
Explore Related AI Coding & Architecture Prompts View all β
Claude 3.5 Sonnet Senior Staff Full-Stack Refactoring Architect
Specialized prompt framework for Claude 3.5 Sonnet and Claude 3.7. Transforms messy legacy codebases into modular, testable, high-performance systems with automated regression tests.
cursorCursor AI (.cursorrules) for Next.js 15, React 19 & Tailwind CSS
Stops Cursor from writing outdated Next.js 13 patterns, Pages Router syntax, or deprecated React hooks. Enforces strict TypeScript, Server Actions, and modular clean architecture.
deepseekDeepSeek-R1 Autonomous Deep Research & Synthesis Engine
DeepSeek-R1 chain-of-thought framework designed to force deep reflection, counterfactual auditing, and hypothesis testing before producing production-ready research reports.