[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79XKRT6JSC826XKHHS8CWZC":3,"skill-same:01M79XKRT6JSC826XKHHS8CWZC":60},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":23,"commitSha":24,"skillDirectory":25,"forksCount":13,"repositoryHtmlUrl":26,"repositoryHomepageUrl":27,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":29,"install":30,"resources":43},"01M79XKRT6JSC826XKHHS8CWZC","solana-vulnerability-scanner",null,"Scans Solana programs for 6 critical vulnerabilities including arbitrary CPI, improper PDA validation, missing signer\u002Fownership checks, and sysvar spoofing. Use when auditing Solana\u002FAnchor programs.","Heesho\u002Fraffle-fun","Heesho","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F100749457?v=4","01M79XHBVXHD5BHPJTHXK51VSC","01M79XHBWZQNAH0BTYT9A1RFCW",0,"MIT","https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FDAYBREAK-TOB\u002Fattempt-02\u002Fruntime\u002Fcodex-home\u002Fplugins\u002Fcache\u002Ftrailofbits\u002Fbuilding-secure-contracts\u002F1.2.2\u002Fskills\u002Fsolana-vulnerability-scanner\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: solana-vulnerability-scanner\ndescription: Scans Solana programs for 6 critical vulnerabilities including arbitrary CPI, improper PDA validation, missing signer\u002Fownership checks, and sysvar spoofing. Use when auditing Solana\u002FAnchor programs.\n---\n\n# Solana Vulnerability Scanner\n\n## 1. Purpose\n\nSystematically scan Solana programs (native and Anchor framework) for platform-specific security vulnerabilities related to cross-program invocations, account validation, and program-derived addresses. This skill encodes 6 critical vulnerability patterns unique to Solana's account model.\n\n## 2. When to Use This Skill\n\n- Auditing Solana programs (native Rust or Anchor)\n- Reviewing cross-program invocation (CPI) logic\n- Validating program-derived address (PDA) implementations\n- Pre-launch security assessment of Solana protocols\n- Reviewing account validation patterns\n- Assessing instruction introspection logic\n\n## 3. Platform Detection\n\n### File Extensions & Indicators\n- **Rust files**: `.rs`\n\n### Language\u002FFramework Markers\n```rust\n\u002F\u002F Native Solana program indicators\nuse solana_program::{\n    account_info::AccountInfo,\n    entrypoint,\n    entrypoint::ProgramResult,\n    pubkey::Pubkey,\n    program::invoke,\n    program::invoke_signed,\n};\n\nentrypoint!(process_instruction);\n\n\u002F\u002F Anchor framework indicators\nuse anchor_lang::prelude::*;\n\n#[program]\npub mod my_program {\n    pub fn initialize(ctx: Context\u003CInitialize>) -> Result\u003C()> {\n        \u002F\u002F Program logic\n    }\n}\n\n#[derive(Accounts)]\npub struct Initialize\u003C'info> {\n    #[account(mut)]\n    pub authority: Signer\u003C'info>,\n}\n\n\u002F\u002F Common patterns\nAccountInfo, Pubkey\ninvoke(), invoke_signed()\nSigner\u003C'info>, Account\u003C'info>\n#[account(...)] with constraints\nseeds, bump\n```\n\n### Project Structure\n- `programs\u002F*\u002Fsrc\u002Flib.rs` - Program implementation\n- `Anchor.toml` - Anchor configuration\n- `Cargo.toml` with `solana-program` or `anchor-lang`\n- `tests\u002F` - Program tests\n\n### Tool Support\n- **Trail of Bits Solana Lints**: Rust linters for Solana\n- Installation: Add to Cargo.toml\n- **anchor test**: Built-in testing framework\n- **Solana Test Validator**: Local testing environment\n\n---\n\n## 4. How This Skill Works\n\nWhen invoked, I will:\n\n1. **Search your codebase** for Solana\u002FAnchor programs\n2. **Analyze each program** for the 6 vulnerability patterns\n3. **Report findings** with file references and severity, above them a coverage table carrying a verdict for every pattern\n4. **Provide fixes** for each identified issue\n5. **Check account validation** and CPI security\n\n---\n\n## 5. Example Output\n\n---\n\n## 6. Vulnerability Patterns (6 Patterns)\n\nI check for 6 critical vulnerability patterns unique to Solana. For detailed detection patterns, code examples, mitigations, and testing strategies, see [VULNERABILITY_PATTERNS.md](resources\u002FVULNERABILITY_PATTERNS.md).\n\n### Pattern Summary:\n\n1. **Arbitrary CPI** ⚠️ CRITICAL - User-controlled program IDs in CPI calls\n2. **Improper PDA Validation** ⚠️ CRITICAL - Using create_program_address without canonical bump\n3. **Missing Ownership Check** ⚠️ HIGH - Deserializing accounts without owner validation\n4. **Missing Signer Check** ⚠️ CRITICAL - Authority operations without is_signer check\n5. **Sysvar Account Check** ⚠️ HIGH - Spoofed sysvar accounts (pre-Solana 1.8.1)\n6. **Improper Instruction Introspection** ⚠️ MEDIUM - Absolute indexes allowing reuse\n\nFor complete vulnerability patterns with code examples, see [VULNERABILITY_PATTERNS.md](resources\u002FVULNERABILITY_PATTERNS.md).\n\n## 7. Scanning Workflow\n\n### Step 1: Platform Identification\n1. Verify Solana program (native or Anchor)\n2. Check Solana version (1.8.1+ for sysvar security)\n3. Locate program source (`programs\u002F*\u002Fsrc\u002Flib.rs`)\n4. Identify framework (native vs Anchor)\n\n### Step 2: CPI Security Review\n```bash\n# Find all CPI calls\nrg \"invoke\\(|invoke_signed\\(\" programs\u002F\n\n# Check for program ID validation before each\n# Should see program ID checks immediately before invoke\n```\n\nFor each CPI:\n- [ ] Program ID validated before invocation\n- [ ] Cannot pass user-controlled program accounts\n- [ ] Anchor: Uses `Program\u003C'info, T>` type\n\n### Step 3: PDA Validation Check\n```bash\n# Find PDA usage\nrg \"find_program_address|create_program_address\" programs\u002F\nrg \"seeds.*bump\" programs\u002F\n\n# Anchor: Check for seeds constraints\nrg \"#\\[account.*seeds\" programs\u002F\n```\n\nFor each PDA:\n- [ ] Uses `find_program_address()` or Anchor `seeds` constraint\n- [ ] Bump seed stored and reused\n- [ ] Not using user-provided bump\n\n### Step 4: Account Validation Sweep\n```bash\n# Find account deserialization\nrg \"try_from_slice|try_deserialize\" programs\u002F\n\n# Should see owner checks before deserialization\nrg \"\\.owner\\s*==|\\.owner\\s*!=\" programs\u002F\n```\n\nFor each account used:\n- [ ] Owner validated before deserialization\n- [ ] Signer check for authority accounts\n- [ ] Anchor: Uses `Account\u003C'info, T>` and `Signer\u003C'info>`\n\n### Step 5: Instruction Introspection Review\n```bash\n# Find instruction introspection usage\nrg \"load_instruction_at|load_current_index|get_instruction_relative\" programs\u002F\n\n# Check for checked versions\nrg \"load_instruction_at_checked|load_current_index_checked\" programs\u002F\n```\n\n- [ ] Using checked functions (Solana 1.8.1+)\n- [ ] Using relative indexing\n- [ ] Proper correlation validation\n\n### Step 6: Trail of Bits Solana Lints\n```toml\n# Add to Cargo.toml\n[dependencies]\nsolana-program = \"1.17\"  # Use latest version\n\n[lints.clippy]\n# Enable Solana-specific lints\n# (Trail of Bits solana-lints if available)\n```\n\n---\n\n## 8. Reporting Format\n\n### Coverage Table\n\nReport on every pattern in §6, whether or not it turned anything up. Emit this table above the findings, with\nall 6 rows present:\n\n| # | Pattern | Verdict | Evidence |\n|---|---------|---------|----------|\n| 1 | Arbitrary CPI | `n\u002Fa` | this program makes no cross-program invocations |\n| 2 | Improper PDA Validation | | |\n| 3 | Missing Ownership Check | | |\n| 4 | Missing Signer Check | | |\n| 5 | Sysvar Account Check | | |\n| 6 | Improper Instruction Introspection | | |\n\nEach verdict is one of:\n\n- **`found`** — cite `file:line` and write the finding up in full below.\n- **`clear`** — the pattern applies to this program and the program handles it. Name the constraint, account\n  type, or check you searched for, so a reader can repeat the search.\n- **`n\u002Fa`** — the pattern cannot apply here. Give the reason in one clause (\"this program makes no CPI calls\").\n  Not having looked is not `n\u002Fa`. Pattern 5 is version-scoped (pre-Solana 1.8.1): cite the `solana-program`\n  version the program targets rather than dropping the row, since \"targets 1.17, fixed upstream\" and \"did not\n  look\" are otherwise the same answer.\n\nA table with fewer than 6 rows is an incomplete scan and must be reported as one. A row whose Verdict cell is empty is incomplete in the same way: row 1 above is filled in to show the shape, and every row is filled in the same way before the report is done. Six `clear` verdicts is a\nresult a reader can act on. A report that covers two patterns and says nothing about the other four reads\nexactly like a clean program, and that is the failure this table exists to prevent.\n\n### Finding Template\n````markdown\n## [CRITICAL] Arbitrary CPI - Unchecked Program ID\n\n**Location**: `programs\u002Fvault\u002Fsrc\u002Flib.rs:145-160` (withdraw function)\n\n**Description**:\nThe `withdraw` function performs a CPI to transfer SPL tokens without validating that the provided `token_program` account is actually the SPL Token program. An attacker can provide a malicious program that appears to perform a transfer but actually steals tokens or performs unauthorized actions.\n\n**Vulnerable Code**:\n```rust\n\u002F\u002F lib.rs, line 145\npub fn withdraw(ctx: Context\u003CWithdraw>, amount: u64) -> Result\u003C()> {\n    let token_program = &ctx.accounts.token_program;\n\n    \u002F\u002F WRONG: No validation of token_program.key()!\n    invoke(\n        &spl_token::instruction::transfer(...),\n        &[\n            ctx.accounts.vault.to_account_info(),\n            ctx.accounts.destination.to_account_info(),\n            ctx.accounts.authority.to_account_info(),\n            token_program.to_account_info(),  \u002F\u002F UNVALIDATED\n        ],\n    )?;\n    Ok(())\n}\n```\n\n**Attack Scenario**:\n1. Attacker deploys malicious \"token program\" that logs transfer instruction but doesn't execute it\n2. Attacker calls withdraw() providing malicious program as token_program\n3. Vault's authority signs the transaction\n4. Malicious program receives CPI with vault's signature\n5. Malicious program can now impersonate vault and drain real tokens\n\n**Recommendation**:\nUse Anchor's `Program\u003C'info, Token>` type:\n```rust\nuse anchor_spl::token::{Token, Transfer};\n\n#[derive(Accounts)]\npub struct Withdraw\u003C'info> {\n    #[account(mut)]\n    pub vault: Account\u003C'info, TokenAccount>,\n    #[account(mut)]\n    pub destination: Account\u003C'info, TokenAccount>,\n    pub authority: Signer\u003C'info>,\n    pub token_program: Program\u003C'info, Token>,  \u002F\u002F Validates program ID automatically\n}\n\npub fn withdraw(ctx: Context\u003CWithdraw>, amount: u64) -> Result\u003C()> {\n    let cpi_accounts = Transfer {\n        from: ctx.accounts.vault.to_account_info(),\n        to: ctx.accounts.destination.to_account_info(),\n        authority: ctx.accounts.authority.to_account_info(),\n    };\n\n    let cpi_ctx = CpiContext::new(\n        ctx.accounts.token_program.to_account_info(),\n        cpi_accounts,\n    );\n\n    anchor_spl::token::transfer(cpi_ctx, amount)?;\n    Ok(())\n}\n```\n\n**References**:\n- building-secure-contracts\u002Fnot-so-smart-contracts\u002Fsolana\u002Farbitrary_cpi\n- Trail of Bits lint: `unchecked-cpi-program-id`\n````\n\n---\n\n## 9. Priority Guidelines\n\n### Critical (Immediate Fix Required)\n- Arbitrary CPI (attacker-controlled program execution)\n- Improper PDA validation (account spoofing)\n- Missing signer check (unauthorized access)\n\n### High (Fix Before Launch)\n- Missing ownership check (fake account data)\n- Sysvar account check (authentication bypass, pre-1.8.1)\n\n### Medium (Address in Audit)\n- Improper instruction introspection (logic bypass)\n\n---\n\n## 10. Testing Recommendations\n\n### Unit Tests\n```rust\n#[cfg(test)]\nmod tests {\n    use super::*;\n\n    #[test]\n    #[should_panic]\n    fn test_rejects_wrong_program_id() {\n        \u002F\u002F Provide wrong program ID, should fail\n    }\n\n    #[test]\n    #[should_panic]\n    fn test_rejects_non_canonical_pda() {\n        \u002F\u002F Provide non-canonical bump, should fail\n    }\n\n    #[test]\n    #[should_panic]\n    fn test_requires_signer() {\n        \u002F\u002F Call without signature, should fail\n    }\n}\n```\n\n### Integration Tests (Anchor)\n```typescript\nimport * as anchor from \"@coral-xyz\u002Fanchor\";\n\ndescribe(\"security tests\", () => {\n  it(\"rejects arbitrary CPI\", async () => {\n    const fakeTokenProgram = anchor.web3.Keypair.generate();\n\n    try {\n      await program.methods\n        .withdraw(amount)\n        .accounts({\n          tokenProgram: fakeTokenProgram.publicKey, \u002F\u002F Wrong program\n        })\n        .rpc();\n\n      assert.fail(\"Should have rejected fake program\");\n    } catch (err) {\n      \u002F\u002F Expected to fail\n    }\n  });\n});\n```\n\n### Solana Test Validator\n```bash\n# Run local validator for testing\nsolana-test-validator\n\n# Deploy and test program\nanchor test\n```\n\n---\n\n## 11. Additional Resources\n\n- **Building Secure Contracts**: `building-secure-contracts\u002Fnot-so-smart-contracts\u002Fsolana\u002F`\n- **Trail of Bits Solana Lints**: https:\u002F\u002Fgithub.com\u002Ftrailofbits\u002Fsolana-lints\n- **Anchor Documentation**: https:\u002F\u002Fwww.anchor-lang.com\u002F\n- **Solana Program Library**: https:\u002F\u002Fgithub.com\u002Fsolana-labs\u002Fsolana-program-library\n- **Solana Cookbook**: https:\u002F\u002Fsolanacookbook.com\u002F\n\n---\n\n## 12. Quick Reference Checklist\n\nBefore completing Solana program audit:\n\n**CPI Security (CRITICAL)**:\n- [ ] ALL CPI calls validate program ID before `invoke()`\n- [ ] Cannot use user-provided program accounts\n- [ ] Anchor: Uses `Program\u003C'info, T>` type\n\n**PDA Security (CRITICAL)**:\n- [ ] PDAs use `find_program_address()` or Anchor `seeds` constraint\n- [ ] Bump seed stored and reused (not user-provided)\n- [ ] PDA accounts validated against canonical address\n\n**Account Validation (HIGH)**:\n- [ ] ALL accounts check owner before deserialization\n- [ ] Native: Validates `account.owner == expected_program_id`\n- [ ] Anchor: Uses `Account\u003C'info, T>` type\n\n**Signer Validation (CRITICAL)**:\n- [ ] ALL authority accounts check `is_signer`\n- [ ] Native: Validates `account.is_signer == true`\n- [ ] Anchor: Uses `Signer\u003C'info>` type\n\n**Sysvar Security (HIGH)**:\n- [ ] Using Solana 1.8.1+\n- [ ] Using checked functions: `load_instruction_at_checked()`\n- [ ] Sysvar addresses validated\n\n**Instruction Introspection (MEDIUM)**:\n- [ ] Using relative indexes for correlation\n- [ ] Proper validation between related instructions\n- [ ] Cannot reuse same instruction across multiple calls\n\n**Testing**:\n- [ ] Unit tests cover all account validation\n- [ ] Integration tests with malicious inputs\n- [ ] Local validator testing completed\n- [ ] Trail of Bits lints enabled and passing\n- [ ] Coverage table emitted with all 6 rows, each carrying a verdict of `found`, `clear` or `n\u002Fa` with a reason\n\n---\n\n## 13. Rationalizations to Reject\n\n- **\"The program is small, so most patterns obviously don't apply.\"** Obvious to whom? An `n\u002Fa` costs one\n  clause and makes the judgment reviewable. Silence records nothing, and a reader cannot tell it apart from\n  not having checked.\n- **\"The Trail of Bits lints pass, so the program is clean.\"** The lints cover a subset of these 6 patterns.\n  A clean lint run is one row of evidence, not a verdict on the patterns it never examined. Say which\n  patterns it covered.\n- **\"I checked the patterns that matter for this program.\"** Deciding which patterns matter *is* the scan,\n  not a precondition for starting it. Rank by severity after the table is complete, not by leaving rows out.\n- **\"No findings, so there is nothing to report.\"** A zero-finding scan still emits the full coverage table.\n  That table is the deliverable: it is what distinguishes a program that was examined from one that was\n  glanced at.\n- **\"Anchor handles account validation.\"** Name the constraint. Anchor validates what the account struct\n  declares and nothing more: `#[account(mut)]` is not an ownership check, and `UncheckedAccount` opts out\n  entirely. Cite the attribute, not the framework.\n- **\"The PDA derivation makes it safe.\"** Derivation is not validation. `create_program_address` without the\n  canonical bump admits multiple valid addresses, which is pattern 2 in full.\n","# Solana Vulnerability Scanner\n\n## 1. Purpose\n\nSystematically scan Solana programs (native and Anchor framework) for platform-specific security vulnerabilities related to cross-program invocations, account validation, and program-derived addresses. This skill encodes 6 critical vulnerability patterns unique to Solana's account model.\n\n## 2. When to Use This Skill\n\n- Auditing Solana programs (native Rust or Anchor)\n- Reviewing cross-program invocation (CPI) logic\n- Validating program-derived address (PDA) implementations\n- Pre-launch security assessment of Solana protocols\n- Reviewing account validation patterns\n- Assessing instruction introspection logic\n\n## 3. Platform Detection\n\n### File Extensions & Indicators\n- **Rust files**: `.rs`\n\n### Language\u002FFramework Markers\n```rust\n\u002F\u002F Native Solana program indicators\nuse solana_program::{\n    account_info::AccountInfo,\n    entrypoint,\n    entrypoint::ProgramResult,\n    pubkey::Pubkey,\n    program::invoke,\n    program::invoke_signed,\n};\n\nentrypoint!(process_instruction);\n\n\u002F\u002F Anchor framework indicators\nuse anchor_lang::prelude::*;\n\n#[program]\npub mod my_program {\n    pub fn initialize(ctx: Context\u003CInitialize>) -> Result\u003C()> {\n        \u002F\u002F Program logic\n    }\n}\n\n#[derive(Accounts)]\npub struct Initialize\u003C'info> {\n    #[account(mut)]\n    pub authority: Signer\u003C'info>,\n}\n\n\u002F\u002F Common patterns\nAccountInfo, Pubkey\ninvoke(), invoke_signed()\nSigner\u003C'info>, Account\u003C'info>\n#[account(...)] with constraints\nseeds, bump\n```\n\n### Project Structure\n- `programs\u002F*\u002Fsrc\u002Flib.rs` - Program implementation\n- `Anchor.toml` - Anchor configuration\n- `Cargo.toml` with `solana-program` or `anchor-lang`\n- `tests\u002F` - Program tests\n\n### Tool Support\n- **Trail of Bits Solana Lints**: Rust linters for Solana\n- Installation: Add to Cargo.toml\n- **anchor test**: Built-in testing framework\n- **Solana Test Validator**: Local testing environment\n\n---\n\n## 4. How This Skill Works\n\nWhen invoked, I will:\n\n1. **Search your codebase** for Solana\u002FAnchor programs\n2. **Analyze each program** for the 6 vulnerability patterns\n3. **Report findings** with file references and severity, above them a coverage table carrying a verdict for every pattern\n4. **Provide fixes** for each identified issue\n5. **Check account validation** and CPI security\n\n---\n\n## 5. Example Output\n\n---\n\n## 6. Vulnerability Patterns (6 Patterns)\n\nI check for 6 critical vulnerability patterns unique to Solana. For detailed detection patterns, code examples, mitigations, and testing strategies, see [VULNERABILITY_PATTERNS.md](resources\u002FVULNERABILITY_PATTERNS.md).\n\n### Pattern Summary:\n\n1. **Arbitrary CPI** ⚠️ CRITICAL - User-controlled program IDs in CPI calls\n2. **Improper PDA Validation** ⚠️ CRITICAL - Using create_program_address without canonical bump\n3. **Missing Ownership Check** ⚠️ HIGH - Deserializing accounts without owner validation\n4. **Missing Signer Check** ⚠️ CRITICAL - Authority operations without is_signer check\n5. **Sysvar Account Check** ⚠️ HIGH - Spoofed sysvar accounts (pre-Solana 1.8.1)\n6. **Improper Instruction Introspection** ⚠️ MEDIUM - Absolute indexes allowing reuse\n\nFor complete vulnerability patterns with code examples, see [VULNERABILITY_PATTERNS.md](resources\u002FVULNERABILITY_PATTERNS.md).\n\n## 7. Scanning Workflow\n\n### Step 1: Platform Identification\n1. Verify Solana program (native or Anchor)\n2. Check Solana version (1.8.1+ for sysvar security)\n3. Locate program source (`programs\u002F*\u002Fsrc\u002Flib.rs`)\n4. Identify framework (native vs Anchor)\n\n### Step 2: CPI Security Review\n```bash\n# Find all CPI calls\nrg \"invoke\\(|invoke_signed\\(\" programs\u002F\n\n# Check for program ID validation before each\n# Should see program ID checks immediately before invoke\n```\n\nFor each CPI:\n- [ ] Program ID validated before invocation\n- [ ] Cannot pass user-controlled program accounts\n- [ ] Anchor: Uses `Program\u003C'info, T>` type\n\n### Step 3: PDA Validation Check\n```bash\n# Find PDA usage\nrg \"find_program_address|create_program_address\" programs\u002F\nrg \"seeds.*bump\" programs\u002F\n\n# Anchor: Check for seeds constraints\nrg \"#\\[account.*seeds\" programs\u002F\n```\n\nFor each PDA:\n- [ ] Uses `find_program_address()` or Anchor `seeds` constraint\n- [ ] Bump seed stored and reused\n- [ ] Not using user-provided bump\n\n### Step 4: Account Validation Sweep\n```bash\n# Find account deserialization\nrg \"try_from_slice|try_deserialize\" programs\u002F\n\n# Should see owner checks before deserialization\nrg \"\\.owner\\s*==|\\.owner\\s*!=\" programs\u002F\n```\n\nFor each account used:\n- [ ] Owner validated before deserialization\n- [ ] Signer check for authority accounts\n- [ ] Anchor: Uses `Account\u003C'info, T>` and `Signer\u003C'info>`\n\n### Step 5: Instruction Introspection Review\n```bash\n# Find instruction introspection usage\nrg \"load_instruction_at|load_current_index|get_instruction_relative\" programs\u002F\n\n# Check for checked versions\nrg \"load_instruction_at_checked|load_current_index_checked\" programs\u002F\n```\n\n- [ ] Using checked functions (Solana 1.8.1+)\n- [ ] Using relative indexing\n- [ ] Proper correlation validation\n\n### Step 6: Trail of Bits Solana Lints\n```toml\n# Add to Cargo.toml\n[dependencies]\nsolana-program = \"1.17\"  # Use latest version\n\n[lints.clippy]\n# Enable Solana-specific lints\n# (Trail of Bits solana-lints if available)\n```\n\n---\n\n## 8. Reporting Format\n\n### Coverage Table\n\nReport on every pattern in §6, whether or not it turned anything up. Emit this table above the findings, with\nall 6 rows present:\n\n| # | Pattern | Verdict | Evidence |\n|---|---------|---------|----------|\n| 1 | Arbitrary CPI | `n\u002Fa` | this program makes no cross-program invocations |\n| 2 | Improper PDA Validation | | |\n| 3 | Missing Ownership Check | | |\n| 4 | Missing Signer Check | | |\n| 5 | Sysvar Account Check | | |\n| 6 | Improper Instruction Introspection | | |\n\nEach verdict is one of:\n\n- **`found`** — cite `file:line` and write the finding up in full below.\n- **`clear`** — the pattern applies to this program and the program handles it. Name the constraint, account\n  type, or check you searched for, so a reader can repeat the search.\n- **`n\u002Fa`** — the pattern cannot apply here. Give the reason in one clause (\"this program makes no CPI calls\").\n  Not having looked is not `n\u002Fa`. Pattern 5 is version-scoped (pre-Solana 1.8.1): cite the `solana-program`\n  version the program targets rather than dropping the row, since \"targets 1.17, fixed upstream\" and \"did not\n  look\" are otherwise the same answer.\n\nA table with fewer than 6 rows is an incomplete scan and must be reported as one. A row whose Verdict cell is empty is incomplete in the same way: row 1 above is filled in to show the shape, and every row is filled in the same way before the report is done. Six `clear` verdicts is a\nresult a reader can act on. A report that covers two patterns and says nothing about the other four reads\nexactly like a clean program, and that is the failure this table exists to prevent.\n\n### Finding Template\n````markdown\n## [CRITICAL] Arbitrary CPI - Unchecked Program ID\n\n**Location**: `programs\u002Fvault\u002Fsrc\u002Flib.rs:145-160` (withdraw function)\n\n**Description**:\nThe `withdraw` function performs a CPI to transfer SPL tokens without validating that the provided `token_program` account is actually the SPL Token program. An attacker can provide a malicious program that appears to perform a transfer but actually steals tokens or performs unauthorized actions.\n\n**Vulnerable Code**:\n```rust\n\u002F\u002F lib.rs, line 145\npub fn withdraw(ctx: Context\u003CWithdraw>, amount: u64) -> Result\u003C()> {\n    let token_program = &ctx.accounts.token_program;\n\n    \u002F\u002F WRONG: No validation of token_program.key()!\n    invoke(\n        &spl_token::instruction::transfer(...),\n        &[\n            ctx.accounts.vault.to_account_info(),\n            ctx.accounts.destination.to_account_info(),\n            ctx.accounts.authority.to_account_info(),\n            token_program.to_account_info(),  \u002F\u002F UNVALIDATED\n        ],\n    )?;\n    Ok(())\n}\n```\n\n**Attack Scenario**:\n1. Attacker deploys malicious \"token program\" that logs transfer instruction but doesn't execute it\n2. Attacker calls withdraw() providing malicious program as token_program\n3. Vault's authority signs the transaction\n4. Malicious program receives CPI with vault's signature\n5. Malicious program can now impersonate vault and drain real tokens\n\n**Recommendation**:\nUse Anchor's `Program\u003C'info, Token>` type:\n```rust\nuse anchor_spl::token::{Token, Transfer};\n\n#[derive(Accounts)]\npub struct Withdraw\u003C'info> {\n    #[account(mut)]\n    pub vault: Account\u003C'info, TokenAccount>,\n    #[account(mut)]\n    pub destination: Account\u003C'info, TokenAccount>,\n    pub authority: Signer\u003C'info>,\n    pub token_program: Program\u003C'info, Token>,  \u002F\u002F Validates program ID automatically\n}\n\npub fn withdraw(ctx: Context\u003CWithdraw>, amount: u64) -> Result\u003C()> {\n    let cpi_accounts = Transfer {\n        from: ctx.accounts.vault.to_account_info(),\n        to: ctx.accounts.destination.to_account_info(),\n        authority: ctx.accounts.authority.to_account_info(),\n    };\n\n    let cpi_ctx = CpiContext::new(\n        ctx.accounts.token_program.to_account_info(),\n        cpi_accounts,\n    );\n\n    anchor_spl::token::transfer(cpi_ctx, amount)?;\n    Ok(())\n}\n```\n\n**References**:\n- building-secure-contracts\u002Fnot-so-smart-contracts\u002Fsolana\u002Farbitrary_cpi\n- Trail of Bits lint: `unchecked-cpi-program-id`\n````\n\n---\n\n## 9. Priority Guidelines\n\n### Critical (Immediate Fix Required)\n- Arbitrary CPI (attacker-controlled program execution)\n- Improper PDA validation (account spoofing)\n- Missing signer check (unauthorized access)\n\n### High (Fix Before Launch)\n- Missing ownership check (fake account data)\n- Sysvar account check (authentication bypass, pre-1.8.1)\n\n### Medium (Address in Audit)\n- Improper instruction introspection (logic bypass)\n\n---\n\n## 10. Testing Recommendations\n\n### Unit Tests\n```rust\n#[cfg(test)]\nmod tests {\n    use super::*;\n\n    #[test]\n    #[should_panic]\n    fn test_rejects_wrong_program_id() {\n        \u002F\u002F Provide wrong program ID, should fail\n    }\n\n    #[test]\n    #[should_panic]\n    fn test_rejects_non_canonical_pda() {\n        \u002F\u002F Provide non-canonical bump, should fail\n    }\n\n    #[test]\n    #[should_panic]\n    fn test_requires_signer() {\n        \u002F\u002F Call without signature, should fail\n    }\n}\n```\n\n### Integration Tests (Anchor)\n```typescript\nimport * as anchor from \"@coral-xyz\u002Fanchor\";\n\ndescribe(\"security tests\", () => {\n  it(\"rejects arbitrary CPI\", async () => {\n    const fakeTokenProgram = anchor.web3.Keypair.generate();\n\n    try {\n      await program.methods\n        .withdraw(amount)\n        .accounts({\n          tokenProgram: fakeTokenProgram.publicKey, \u002F\u002F Wrong program\n        })\n        .rpc();\n\n      assert.fail(\"Should have rejected fake program\");\n    } catch (err) {\n      \u002F\u002F Expected to fail\n    }\n  });\n});\n```\n\n### Solana Test Validator\n```bash\n# Run local validator for testing\nsolana-test-validator\n\n# Deploy and test program\nanchor test\n```\n\n---\n\n## 11. Additional Resources\n\n- **Building Secure Contracts**: `building-secure-contracts\u002Fnot-so-smart-contracts\u002Fsolana\u002F`\n- **Trail of Bits Solana Lints**: https:\u002F\u002Fgithub.com\u002Ftrailofbits\u002Fsolana-lints\n- **Anchor Documentation**: https:\u002F\u002Fwww.anchor-lang.com\u002F\n- **Solana Program Library**: https:\u002F\u002Fgithub.com\u002Fsolana-labs\u002Fsolana-program-library\n- **Solana Cookbook**: https:\u002F\u002Fsolanacookbook.com\u002F\n\n---\n\n## 12. Quick Reference Checklist\n\nBefore completing Solana program audit:\n\n**CPI Security (CRITICAL)**:\n- [ ] ALL CPI calls validate program ID before `invoke()`\n- [ ] Cannot use user-provided program accounts\n- [ ] Anchor: Uses `Program\u003C'info, T>` type\n\n**PDA Security (CRITICAL)**:\n- [ ] PDAs use `find_program_address()` or Anchor `seeds` constraint\n- [ ] Bump seed stored and reused (not user-provided)\n- [ ] PDA accounts validated against canonical address\n\n**Account Validation (HIGH)**:\n- [ ] ALL accounts check owner before deserialization\n- [ ] Native: Validates `account.owner == expected_program_id`\n- [ ] Anchor: Uses `Account\u003C'info, T>` type\n\n**Signer Validation (CRITICAL)**:\n- [ ] ALL authority accounts check `is_signer`\n- [ ] Native: Validates `account.is_signer == true`\n- [ ] Anchor: Uses `Signer\u003C'info>` type\n\n**Sysvar Security (HIGH)**:\n- [ ] Using Solana 1.8.1+\n- [ ] Using checked functions: `load_instruction_at_checked()`\n- [ ] Sysvar addresses validated\n\n**Instruction Introspection (MEDIUM)**:\n- [ ] Using relative indexes for correlation\n- [ ] Proper validation between related instructions\n- [ ] Cannot reuse same instruction across multiple calls\n\n**Testing**:\n- [ ] Unit tests cover all account validation\n- [ ] Integration tests with malicious inputs\n- [ ] Local validator testing completed\n- [ ] Trail of Bits lints enabled and passing\n- [ ] Coverage table emitted with all 6 rows, each carrying a verdict of `found`, `clear` or `n\u002Fa` with a reason\n\n---\n\n## 13. Rationalizations to Reject\n\n- **\"The program is small, so most patterns obviously don't apply.\"** Obvious to whom? An `n\u002Fa` costs one\n  clause and makes the judgment reviewable. Silence records nothing, and a reader cannot tell it apart from\n  not having checked.\n- **\"The Trail of Bits lints pass, so the program is clean.\"** The lints cover a subset of these 6 patterns.\n  A clean lint run is one row of evidence, not a verdict on the patterns it never examined. Say which\n  patterns it covered.\n- **\"I checked the patterns that matter for this program.\"** Deciding which patterns matter *is* the scan,\n  not a precondition for starting it. Rank by severity after the table is complete, not by leaving rows out.\n- **\"No findings, so there is nothing to report.\"** A zero-finding scan still emits the full coverage table.\n  That table is the deliverable: it is what distinguishes a program that was examined from one that was\n  glanced at.\n- **\"Anchor handles account validation.\"** Name the constraint. Anchor validates what the account struct\n  declares and nothing more: `#[account(mut)]` is not an ownership check, and `UncheckedAccount` opts out\n  entirely. Cite the attribute, not the framework.\n- **\"The PDA derivation makes it safe.\"** Derivation is not validation. `create_program_address` without the\n  canonical bump admits multiple valid addresses, which is pattern 2 in full.\n",{"name":5,"description":7},"main","aa4fc8e4a5441efccc61aca4e77753a2e9f88c8b","audits\u002F2026-10-21-r001\u002Fruns\u002FDAYBREAK-TOB\u002Fattempt-02\u002Fruntime\u002Fcodex-home\u002Fplugins\u002Fcache\u002Ftrailofbits\u002Fbuilding-secure-contracts\u002F1.2.2\u002Fskills\u002Fsolana-vulnerability-scanner","https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun","https:\u002F\u002Fraffle-fun-lake.vercel.app","https:\u002F\u002Fgithub.com\u002FHeesho","2026-10-22 13:02:00",{"source":8,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add Heesho\u002Fraffle-fun --skill solana-vulnerability-scanner",{"tool":36,"command":37},"bunx","bunx skills add Heesho\u002Fraffle-fun --skill solana-vulnerability-scanner",{"tool":39,"command":40},"pnpm","pnpm dlx skills add Heesho\u002Fraffle-fun --skill solana-vulnerability-scanner","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FDAYBREAK-TOB\u002Fattempt-02\u002Fruntime\u002Fcodex-home\u002Fplugins\u002Fcache\u002Ftrailofbits\u002Fbuilding-secure-contracts\u002F1.2.2\u002Fskills\u002Fsolana-vulnerability-scanner\u002FSKILL.md",true,[44,50,56],{"path":45,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":48,"sourceHtmlUrl":49},"agents\u002Fopenai.yaml","REFERENCE","参考文档",258,"https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FDAYBREAK-TOB\u002Fattempt-02\u002Fruntime\u002Fcodex-home\u002Fplugins\u002Fcache\u002Ftrailofbits\u002Fbuilding-secure-contracts\u002F1.2.2\u002Fskills\u002Fsolana-vulnerability-scanner\u002Fagents\u002Fopenai.yaml",{"path":51,"resourceType":52,"resourceTypeDesc":53,"sizeBytes":54,"sourceHtmlUrl":55},"assets\u002Ftrail-of-bits-mark.svg","ASSET","资产文件",3084,"https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FDAYBREAK-TOB\u002Fattempt-02\u002Fruntime\u002Fcodex-home\u002Fplugins\u002Fcache\u002Ftrailofbits\u002Fbuilding-secure-contracts\u002F1.2.2\u002Fskills\u002Fsolana-vulnerability-scanner\u002Fassets\u002Ftrail-of-bits-mark.svg",{"path":57,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":58,"sourceHtmlUrl":59},"resources\u002FVULNERABILITY_PATTERNS.md",20338,"https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FDAYBREAK-TOB\u002Fattempt-02\u002Fruntime\u002Fcodex-home\u002Fplugins\u002Fcache\u002Ftrailofbits\u002Fbuilding-secure-contracts\u002F1.2.2\u002Fskills\u002Fsolana-vulnerability-scanner\u002Fresources\u002FVULNERABILITY_PATTERNS.md",[61,68,75,82,87,94],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":18},"01M79XNCGXQ9R07VAPFB1H1WNF","spec-to-code-compliance","Check code against the documentation that specifies it - which requirements hold, which the code contradicts, which are absent, and what the code does that no document mentions. Use when comparing an implementation against a whitepaper, protocol spec, or design document.","https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FOPENAI-TOB\u002Fattempt-02\u002FS5\u002Fresources\u002Fskills\u002Fspec-to-code-compliance\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":18},"01M79XN7ADEZVW17912WC2CM7R","0xsimao-ai","Accounting-first smart contract security audit in the style of 0xSimao — maps the protocol's money model, then attacks it with 12 parallel lenses derived from his 869 published findings. Trigger on \"0xsimao ai\", \"0xsimao audit\", \"audit\", \"simao audit\", \"check this contract\", \"review for security\". Modes - default (full repo) or a specific filename.","https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FOPENAI-SIMAO\u002Fattempt-01\u002Fresources\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":18},"01M79XN26B8ZCW79FATC4TSXA5","solidity-auditor","Security audit of Solidity code while you develop. Trigger on \"audit\", \"check this contract\", \"review for security\", \"loop mode\", \"run the auditor in loop mode\", \"run 3 passes\". Modes - default (full repo) or a specific filename. Loop mode runs several passes in one scan, each pass told what the earlier ones found, and ends in one combined report; it remembers findings between scans in a ledger.","https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FOPENAI-PASHOV\u002Fattempt-01\u002Fharness-reference\u002FSKILL.md",[],[],{"skillNo":83,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":18},"01M79XMX0BKWJN0T8HZEBWTB6P","https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FDAYBREAK-TOB\u002Fattempt-02\u002Fruntime\u002Fcodex-home\u002Fplugins\u002Fcache\u002Ftrailofbits\u002Fspec-to-code-compliance\u002F2.0.2\u002Fskills\u002Fspec-to-code-compliance\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":18},"01M79XMM06CBG09CMZ5N8PGAZ1","entry-point-analyzer","Analyzes smart contract codebases to identify state-changing entry points for security auditing. Detects externally callable functions that modify state, categorizes them by access level (public, admin, role-restricted, contract-only), and generates structured audit reports. Excludes view\u002Fpure\u002Fread-only functions. Use when auditing smart contracts (Solidity, Vyper, Solana\u002FRust, Move, TON, CosmWasm) or when asked to find entry points, audit flows, external functions, access control patterns, or privileged operations.","https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FDAYBREAK-TOB\u002Fattempt-02\u002Fruntime\u002Fcodex-home\u002Fplugins\u002Fcache\u002Ftrailofbits\u002Fentry-point-analyzer\u002F1.0.4\u002Fskills\u002Fentry-point-analyzer\u002FSKILL.md",[],[],{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":18},"01M79XMCTG9288DZNAM1R3K2K2","ton-vulnerability-scanner","Scans TON (The Open Network) smart contracts for 3 critical vulnerabilities including integer-as-boolean misuse, fake Jetton contracts, and forward TON without gas checks. Use when auditing FunC contracts.","https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FDAYBREAK-TOB\u002Fattempt-02\u002Fruntime\u002Fcodex-home\u002Fplugins\u002Fcache\u002Ftrailofbits\u002Fbuilding-secure-contracts\u002F1.2.2\u002Fskills\u002Fton-vulnerability-scanner\u002FSKILL.md",[],[]]