[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-trail-of-bits-solana-vulnerability-scanner":3,"mdc--kaff0h-key":41,"related-org-trail-of-bits-solana-vulnerability-scanner":3054,"related-repo-trail-of-bits-solana-vulnerability-scanner":3205},{"slug":4,"name":4,"fn":5,"description":6,"org":7,"tags":12,"stars":29,"repoUrl":30,"updatedAt":31,"license":32,"forks":33,"topics":34,"repo":36,"sourceUrl":39,"mdContent":40},"solana-vulnerability-scanner","scan Solana programs for vulnerabilities","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.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},"trail-of-bits","Trail of Bits","https:\u002F\u002Fpexgzepcugksgbtrxkhf.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Forg-logos\u002Ftrail-of-bits.png","trailofbits",[13,17,20,23,26],{"name":14,"slug":15,"type":16},"Security","security","tag",{"name":18,"slug":19,"type":16},"Audit","audit",{"name":21,"slug":22,"type":16},"Smart Contracts","smart-contracts",{"name":24,"slug":25,"type":16},"Solana","solana",{"name":27,"slug":28,"type":16},"Code Analysis","code-analysis",6139,"https:\u002F\u002Fgithub.com\u002Ftrailofbits\u002Fskills","2026-07-18T05:47:39.676446",null,541,[35],"agent-skills",{"repoUrl":30,"stars":29,"forks":33,"topics":37,"description":38},[35],"Trail of Bits Claude Code skills for security research, vulnerability detection, and audit workflows","https:\u002F\u002Fgithub.com\u002Ftrailofbits\u002Fskills\u002Ftree\u002FHEAD\u002Fplugins\u002Fbuilding-secure-contracts\u002Fskills\u002Fsolana-vulnerability-scanner","---\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\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### 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",{"data":42,"body":43},{"name":4,"description":6},{"type":44,"children":45},"root",[46,54,61,67,73,108,114,121,142,148,463,469,530,536,574,578,584,589,643,646,652,655,661,675,681,744,754,760,766,796,802,874,879,922,928,1030,1035,1082,1088,1166,1171,1215,1221,1299,1330,1336,1400,1403,1409,1415,1736,1746,1774,1792,2003,2012,2031,2041,2047,2546,2551,2602,2605,2611,2689,2692,2698,2703,2712,2754,2763,2806,2815,2857,2866,2913,2922,2959,2968,2999,3008,3048],{"type":47,"tag":48,"props":49,"children":50},"element","h1",{"id":4},[51],{"type":52,"value":53},"text","Solana Vulnerability Scanner",{"type":47,"tag":55,"props":56,"children":58},"h2",{"id":57},"_1-purpose",[59],{"type":52,"value":60},"1. Purpose",{"type":47,"tag":62,"props":63,"children":64},"p",{},[65],{"type":52,"value":66},"Systematically 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.",{"type":47,"tag":55,"props":68,"children":70},{"id":69},"_2-when-to-use-this-skill",[71],{"type":52,"value":72},"2. When to Use This Skill",{"type":47,"tag":74,"props":75,"children":76},"ul",{},[77,83,88,93,98,103],{"type":47,"tag":78,"props":79,"children":80},"li",{},[81],{"type":52,"value":82},"Auditing Solana programs (native Rust or Anchor)",{"type":47,"tag":78,"props":84,"children":85},{},[86],{"type":52,"value":87},"Reviewing cross-program invocation (CPI) logic",{"type":47,"tag":78,"props":89,"children":90},{},[91],{"type":52,"value":92},"Validating program-derived address (PDA) implementations",{"type":47,"tag":78,"props":94,"children":95},{},[96],{"type":52,"value":97},"Pre-launch security assessment of Solana protocols",{"type":47,"tag":78,"props":99,"children":100},{},[101],{"type":52,"value":102},"Reviewing account validation patterns",{"type":47,"tag":78,"props":104,"children":105},{},[106],{"type":52,"value":107},"Assessing instruction introspection logic",{"type":47,"tag":55,"props":109,"children":111},{"id":110},"_3-platform-detection",[112],{"type":52,"value":113},"3. Platform Detection",{"type":47,"tag":115,"props":116,"children":118},"h3",{"id":117},"file-extensions-indicators",[119],{"type":52,"value":120},"File Extensions & Indicators",{"type":47,"tag":74,"props":122,"children":123},{},[124],{"type":47,"tag":78,"props":125,"children":126},{},[127,133,135],{"type":47,"tag":128,"props":129,"children":130},"strong",{},[131],{"type":52,"value":132},"Rust files",{"type":52,"value":134},": ",{"type":47,"tag":136,"props":137,"children":139},"code",{"className":138},[],[140],{"type":52,"value":141},".rs",{"type":47,"tag":115,"props":143,"children":145},{"id":144},"languageframework-markers",[146],{"type":52,"value":147},"Language\u002FFramework Markers",{"type":47,"tag":149,"props":150,"children":155},"pre",{"className":151,"code":152,"language":153,"meta":154,"style":154},"language-rust shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\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","rust","",[156],{"type":47,"tag":136,"props":157,"children":158},{"__ignoreMap":154},[159,170,179,188,197,206,215,224,233,242,252,261,269,278,287,295,304,313,322,331,340,349,357,366,375,384,393,401,409,418,427,436,445,454],{"type":47,"tag":160,"props":161,"children":164},"span",{"class":162,"line":163},"line",1,[165],{"type":47,"tag":160,"props":166,"children":167},{},[168],{"type":52,"value":169},"\u002F\u002F Native Solana program indicators\n",{"type":47,"tag":160,"props":171,"children":173},{"class":162,"line":172},2,[174],{"type":47,"tag":160,"props":175,"children":176},{},[177],{"type":52,"value":178},"use solana_program::{\n",{"type":47,"tag":160,"props":180,"children":182},{"class":162,"line":181},3,[183],{"type":47,"tag":160,"props":184,"children":185},{},[186],{"type":52,"value":187},"    account_info::AccountInfo,\n",{"type":47,"tag":160,"props":189,"children":191},{"class":162,"line":190},4,[192],{"type":47,"tag":160,"props":193,"children":194},{},[195],{"type":52,"value":196},"    entrypoint,\n",{"type":47,"tag":160,"props":198,"children":200},{"class":162,"line":199},5,[201],{"type":47,"tag":160,"props":202,"children":203},{},[204],{"type":52,"value":205},"    entrypoint::ProgramResult,\n",{"type":47,"tag":160,"props":207,"children":209},{"class":162,"line":208},6,[210],{"type":47,"tag":160,"props":211,"children":212},{},[213],{"type":52,"value":214},"    pubkey::Pubkey,\n",{"type":47,"tag":160,"props":216,"children":218},{"class":162,"line":217},7,[219],{"type":47,"tag":160,"props":220,"children":221},{},[222],{"type":52,"value":223},"    program::invoke,\n",{"type":47,"tag":160,"props":225,"children":227},{"class":162,"line":226},8,[228],{"type":47,"tag":160,"props":229,"children":230},{},[231],{"type":52,"value":232},"    program::invoke_signed,\n",{"type":47,"tag":160,"props":234,"children":236},{"class":162,"line":235},9,[237],{"type":47,"tag":160,"props":238,"children":239},{},[240],{"type":52,"value":241},"};\n",{"type":47,"tag":160,"props":243,"children":245},{"class":162,"line":244},10,[246],{"type":47,"tag":160,"props":247,"children":249},{"emptyLinePlaceholder":248},true,[250],{"type":52,"value":251},"\n",{"type":47,"tag":160,"props":253,"children":255},{"class":162,"line":254},11,[256],{"type":47,"tag":160,"props":257,"children":258},{},[259],{"type":52,"value":260},"entrypoint!(process_instruction);\n",{"type":47,"tag":160,"props":262,"children":264},{"class":162,"line":263},12,[265],{"type":47,"tag":160,"props":266,"children":267},{"emptyLinePlaceholder":248},[268],{"type":52,"value":251},{"type":47,"tag":160,"props":270,"children":272},{"class":162,"line":271},13,[273],{"type":47,"tag":160,"props":274,"children":275},{},[276],{"type":52,"value":277},"\u002F\u002F Anchor framework indicators\n",{"type":47,"tag":160,"props":279,"children":281},{"class":162,"line":280},14,[282],{"type":47,"tag":160,"props":283,"children":284},{},[285],{"type":52,"value":286},"use anchor_lang::prelude::*;\n",{"type":47,"tag":160,"props":288,"children":290},{"class":162,"line":289},15,[291],{"type":47,"tag":160,"props":292,"children":293},{"emptyLinePlaceholder":248},[294],{"type":52,"value":251},{"type":47,"tag":160,"props":296,"children":298},{"class":162,"line":297},16,[299],{"type":47,"tag":160,"props":300,"children":301},{},[302],{"type":52,"value":303},"#[program]\n",{"type":47,"tag":160,"props":305,"children":307},{"class":162,"line":306},17,[308],{"type":47,"tag":160,"props":309,"children":310},{},[311],{"type":52,"value":312},"pub mod my_program {\n",{"type":47,"tag":160,"props":314,"children":316},{"class":162,"line":315},18,[317],{"type":47,"tag":160,"props":318,"children":319},{},[320],{"type":52,"value":321},"    pub fn initialize(ctx: Context\u003CInitialize>) -> Result\u003C()> {\n",{"type":47,"tag":160,"props":323,"children":325},{"class":162,"line":324},19,[326],{"type":47,"tag":160,"props":327,"children":328},{},[329],{"type":52,"value":330},"        \u002F\u002F Program logic\n",{"type":47,"tag":160,"props":332,"children":334},{"class":162,"line":333},20,[335],{"type":47,"tag":160,"props":336,"children":337},{},[338],{"type":52,"value":339},"    }\n",{"type":47,"tag":160,"props":341,"children":343},{"class":162,"line":342},21,[344],{"type":47,"tag":160,"props":345,"children":346},{},[347],{"type":52,"value":348},"}\n",{"type":47,"tag":160,"props":350,"children":352},{"class":162,"line":351},22,[353],{"type":47,"tag":160,"props":354,"children":355},{"emptyLinePlaceholder":248},[356],{"type":52,"value":251},{"type":47,"tag":160,"props":358,"children":360},{"class":162,"line":359},23,[361],{"type":47,"tag":160,"props":362,"children":363},{},[364],{"type":52,"value":365},"#[derive(Accounts)]\n",{"type":47,"tag":160,"props":367,"children":369},{"class":162,"line":368},24,[370],{"type":47,"tag":160,"props":371,"children":372},{},[373],{"type":52,"value":374},"pub struct Initialize\u003C'info> {\n",{"type":47,"tag":160,"props":376,"children":378},{"class":162,"line":377},25,[379],{"type":47,"tag":160,"props":380,"children":381},{},[382],{"type":52,"value":383},"    #[account(mut)]\n",{"type":47,"tag":160,"props":385,"children":387},{"class":162,"line":386},26,[388],{"type":47,"tag":160,"props":389,"children":390},{},[391],{"type":52,"value":392},"    pub authority: Signer\u003C'info>,\n",{"type":47,"tag":160,"props":394,"children":396},{"class":162,"line":395},27,[397],{"type":47,"tag":160,"props":398,"children":399},{},[400],{"type":52,"value":348},{"type":47,"tag":160,"props":402,"children":404},{"class":162,"line":403},28,[405],{"type":47,"tag":160,"props":406,"children":407},{"emptyLinePlaceholder":248},[408],{"type":52,"value":251},{"type":47,"tag":160,"props":410,"children":412},{"class":162,"line":411},29,[413],{"type":47,"tag":160,"props":414,"children":415},{},[416],{"type":52,"value":417},"\u002F\u002F Common patterns\n",{"type":47,"tag":160,"props":419,"children":421},{"class":162,"line":420},30,[422],{"type":47,"tag":160,"props":423,"children":424},{},[425],{"type":52,"value":426},"AccountInfo, Pubkey\n",{"type":47,"tag":160,"props":428,"children":430},{"class":162,"line":429},31,[431],{"type":47,"tag":160,"props":432,"children":433},{},[434],{"type":52,"value":435},"invoke(), invoke_signed()\n",{"type":47,"tag":160,"props":437,"children":439},{"class":162,"line":438},32,[440],{"type":47,"tag":160,"props":441,"children":442},{},[443],{"type":52,"value":444},"Signer\u003C'info>, Account\u003C'info>\n",{"type":47,"tag":160,"props":446,"children":448},{"class":162,"line":447},33,[449],{"type":47,"tag":160,"props":450,"children":451},{},[452],{"type":52,"value":453},"#[account(...)] with constraints\n",{"type":47,"tag":160,"props":455,"children":457},{"class":162,"line":456},34,[458],{"type":47,"tag":160,"props":459,"children":460},{},[461],{"type":52,"value":462},"seeds, bump\n",{"type":47,"tag":115,"props":464,"children":466},{"id":465},"project-structure",[467],{"type":52,"value":468},"Project Structure",{"type":47,"tag":74,"props":470,"children":471},{},[472,483,494,519],{"type":47,"tag":78,"props":473,"children":474},{},[475,481],{"type":47,"tag":136,"props":476,"children":478},{"className":477},[],[479],{"type":52,"value":480},"programs\u002F*\u002Fsrc\u002Flib.rs",{"type":52,"value":482}," - Program implementation",{"type":47,"tag":78,"props":484,"children":485},{},[486,492],{"type":47,"tag":136,"props":487,"children":489},{"className":488},[],[490],{"type":52,"value":491},"Anchor.toml",{"type":52,"value":493}," - Anchor configuration",{"type":47,"tag":78,"props":495,"children":496},{},[497,503,505,511,513],{"type":47,"tag":136,"props":498,"children":500},{"className":499},[],[501],{"type":52,"value":502},"Cargo.toml",{"type":52,"value":504}," with ",{"type":47,"tag":136,"props":506,"children":508},{"className":507},[],[509],{"type":52,"value":510},"solana-program",{"type":52,"value":512}," or ",{"type":47,"tag":136,"props":514,"children":516},{"className":515},[],[517],{"type":52,"value":518},"anchor-lang",{"type":47,"tag":78,"props":520,"children":521},{},[522,528],{"type":47,"tag":136,"props":523,"children":525},{"className":524},[],[526],{"type":52,"value":527},"tests\u002F",{"type":52,"value":529}," - Program tests",{"type":47,"tag":115,"props":531,"children":533},{"id":532},"tool-support",[534],{"type":52,"value":535},"Tool Support",{"type":47,"tag":74,"props":537,"children":538},{},[539,549,554,564],{"type":47,"tag":78,"props":540,"children":541},{},[542,547],{"type":47,"tag":128,"props":543,"children":544},{},[545],{"type":52,"value":546},"Trail of Bits Solana Lints",{"type":52,"value":548},": Rust linters for Solana",{"type":47,"tag":78,"props":550,"children":551},{},[552],{"type":52,"value":553},"Installation: Add to Cargo.toml",{"type":47,"tag":78,"props":555,"children":556},{},[557,562],{"type":47,"tag":128,"props":558,"children":559},{},[560],{"type":52,"value":561},"anchor test",{"type":52,"value":563},": Built-in testing framework",{"type":47,"tag":78,"props":565,"children":566},{},[567,572],{"type":47,"tag":128,"props":568,"children":569},{},[570],{"type":52,"value":571},"Solana Test Validator",{"type":52,"value":573},": Local testing environment",{"type":47,"tag":575,"props":576,"children":577},"hr",{},[],{"type":47,"tag":55,"props":579,"children":581},{"id":580},"_4-how-this-skill-works",[582],{"type":52,"value":583},"4. How This Skill Works",{"type":47,"tag":62,"props":585,"children":586},{},[587],{"type":52,"value":588},"When invoked, I will:",{"type":47,"tag":590,"props":591,"children":592},"ol",{},[593,603,613,623,633],{"type":47,"tag":78,"props":594,"children":595},{},[596,601],{"type":47,"tag":128,"props":597,"children":598},{},[599],{"type":52,"value":600},"Search your codebase",{"type":52,"value":602}," for Solana\u002FAnchor programs",{"type":47,"tag":78,"props":604,"children":605},{},[606,611],{"type":47,"tag":128,"props":607,"children":608},{},[609],{"type":52,"value":610},"Analyze each program",{"type":52,"value":612}," for the 6 vulnerability patterns",{"type":47,"tag":78,"props":614,"children":615},{},[616,621],{"type":47,"tag":128,"props":617,"children":618},{},[619],{"type":52,"value":620},"Report findings",{"type":52,"value":622}," with file references and severity",{"type":47,"tag":78,"props":624,"children":625},{},[626,631],{"type":47,"tag":128,"props":627,"children":628},{},[629],{"type":52,"value":630},"Provide fixes",{"type":52,"value":632}," for each identified issue",{"type":47,"tag":78,"props":634,"children":635},{},[636,641],{"type":47,"tag":128,"props":637,"children":638},{},[639],{"type":52,"value":640},"Check account validation",{"type":52,"value":642}," and CPI security",{"type":47,"tag":575,"props":644,"children":645},{},[],{"type":47,"tag":55,"props":647,"children":649},{"id":648},"_5-example-output",[650],{"type":52,"value":651},"5. Example Output",{"type":47,"tag":575,"props":653,"children":654},{},[],{"type":47,"tag":55,"props":656,"children":658},{"id":657},"_6-vulnerability-patterns-6-patterns",[659],{"type":52,"value":660},"6. Vulnerability Patterns (6 Patterns)",{"type":47,"tag":62,"props":662,"children":663},{},[664,666,673],{"type":52,"value":665},"I check for 6 critical vulnerability patterns unique to Solana. For detailed detection patterns, code examples, mitigations, and testing strategies, see ",{"type":47,"tag":667,"props":668,"children":670},"a",{"href":669},"resources\u002FVULNERABILITY_PATTERNS.md",[671],{"type":52,"value":672},"VULNERABILITY_PATTERNS.md",{"type":52,"value":674},".",{"type":47,"tag":115,"props":676,"children":678},{"id":677},"pattern-summary",[679],{"type":52,"value":680},"Pattern Summary:",{"type":47,"tag":590,"props":682,"children":683},{},[684,694,704,714,724,734],{"type":47,"tag":78,"props":685,"children":686},{},[687,692],{"type":47,"tag":128,"props":688,"children":689},{},[690],{"type":52,"value":691},"Arbitrary CPI",{"type":52,"value":693}," ⚠️ CRITICAL - User-controlled program IDs in CPI calls",{"type":47,"tag":78,"props":695,"children":696},{},[697,702],{"type":47,"tag":128,"props":698,"children":699},{},[700],{"type":52,"value":701},"Improper PDA Validation",{"type":52,"value":703}," ⚠️ CRITICAL - Using create_program_address without canonical bump",{"type":47,"tag":78,"props":705,"children":706},{},[707,712],{"type":47,"tag":128,"props":708,"children":709},{},[710],{"type":52,"value":711},"Missing Ownership Check",{"type":52,"value":713}," ⚠️ HIGH - Deserializing accounts without owner validation",{"type":47,"tag":78,"props":715,"children":716},{},[717,722],{"type":47,"tag":128,"props":718,"children":719},{},[720],{"type":52,"value":721},"Missing Signer Check",{"type":52,"value":723}," ⚠️ CRITICAL - Authority operations without is_signer check",{"type":47,"tag":78,"props":725,"children":726},{},[727,732],{"type":47,"tag":128,"props":728,"children":729},{},[730],{"type":52,"value":731},"Sysvar Account Check",{"type":52,"value":733}," ⚠️ HIGH - Spoofed sysvar accounts (pre-Solana 1.8.1)",{"type":47,"tag":78,"props":735,"children":736},{},[737,742],{"type":47,"tag":128,"props":738,"children":739},{},[740],{"type":52,"value":741},"Improper Instruction Introspection",{"type":52,"value":743}," ⚠️ MEDIUM - Absolute indexes allowing reuse",{"type":47,"tag":62,"props":745,"children":746},{},[747,749,753],{"type":52,"value":748},"For complete vulnerability patterns with code examples, see ",{"type":47,"tag":667,"props":750,"children":751},{"href":669},[752],{"type":52,"value":672},{"type":52,"value":674},{"type":47,"tag":55,"props":755,"children":757},{"id":756},"_7-scanning-workflow",[758],{"type":52,"value":759},"7. Scanning Workflow",{"type":47,"tag":115,"props":761,"children":763},{"id":762},"step-1-platform-identification",[764],{"type":52,"value":765},"Step 1: Platform Identification",{"type":47,"tag":590,"props":767,"children":768},{},[769,774,779,791],{"type":47,"tag":78,"props":770,"children":771},{},[772],{"type":52,"value":773},"Verify Solana program (native or Anchor)",{"type":47,"tag":78,"props":775,"children":776},{},[777],{"type":52,"value":778},"Check Solana version (1.8.1+ for sysvar security)",{"type":47,"tag":78,"props":780,"children":781},{},[782,784,789],{"type":52,"value":783},"Locate program source (",{"type":47,"tag":136,"props":785,"children":787},{"className":786},[],[788],{"type":52,"value":480},{"type":52,"value":790},")",{"type":47,"tag":78,"props":792,"children":793},{},[794],{"type":52,"value":795},"Identify framework (native vs Anchor)",{"type":47,"tag":115,"props":797,"children":799},{"id":798},"step-2-cpi-security-review",[800],{"type":52,"value":801},"Step 2: CPI Security Review",{"type":47,"tag":149,"props":803,"children":807},{"className":804,"code":805,"language":806,"meta":154,"style":154},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","# 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","bash",[808],{"type":47,"tag":136,"props":809,"children":810},{"__ignoreMap":154},[811,820,851,858,866],{"type":47,"tag":160,"props":812,"children":813},{"class":162,"line":163},[814],{"type":47,"tag":160,"props":815,"children":817},{"style":816},"--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic",[818],{"type":52,"value":819},"# Find all CPI calls\n",{"type":47,"tag":160,"props":821,"children":822},{"class":162,"line":172},[823,829,835,841,846],{"type":47,"tag":160,"props":824,"children":826},{"style":825},"--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B",[827],{"type":52,"value":828},"rg",{"type":47,"tag":160,"props":830,"children":832},{"style":831},"--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF",[833],{"type":52,"value":834}," \"",{"type":47,"tag":160,"props":836,"children":838},{"style":837},"--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D",[839],{"type":52,"value":840},"invoke\\(|invoke_signed\\(",{"type":47,"tag":160,"props":842,"children":843},{"style":831},[844],{"type":52,"value":845},"\"",{"type":47,"tag":160,"props":847,"children":848},{"style":837},[849],{"type":52,"value":850}," programs\u002F\n",{"type":47,"tag":160,"props":852,"children":853},{"class":162,"line":181},[854],{"type":47,"tag":160,"props":855,"children":856},{"emptyLinePlaceholder":248},[857],{"type":52,"value":251},{"type":47,"tag":160,"props":859,"children":860},{"class":162,"line":190},[861],{"type":47,"tag":160,"props":862,"children":863},{"style":816},[864],{"type":52,"value":865},"# Check for program ID validation before each\n",{"type":47,"tag":160,"props":867,"children":868},{"class":162,"line":199},[869],{"type":47,"tag":160,"props":870,"children":871},{"style":816},[872],{"type":52,"value":873},"# Should see program ID checks immediately before invoke\n",{"type":47,"tag":62,"props":875,"children":876},{},[877],{"type":52,"value":878},"For each CPI:",{"type":47,"tag":74,"props":880,"children":883},{"className":881},[882],"contains-task-list",[884,896,905],{"type":47,"tag":78,"props":885,"children":888},{"className":886},[887],"task-list-item",[889,894],{"type":47,"tag":890,"props":891,"children":893},"input",{"disabled":248,"type":892},"checkbox",[],{"type":52,"value":895}," Program ID validated before invocation",{"type":47,"tag":78,"props":897,"children":899},{"className":898},[887],[900,903],{"type":47,"tag":890,"props":901,"children":902},{"disabled":248,"type":892},[],{"type":52,"value":904}," Cannot pass user-controlled program accounts",{"type":47,"tag":78,"props":906,"children":908},{"className":907},[887],[909,912,914,920],{"type":47,"tag":890,"props":910,"children":911},{"disabled":248,"type":892},[],{"type":52,"value":913}," Anchor: Uses ",{"type":47,"tag":136,"props":915,"children":917},{"className":916},[],[918],{"type":52,"value":919},"Program\u003C'info, T>",{"type":52,"value":921}," type",{"type":47,"tag":115,"props":923,"children":925},{"id":924},"step-3-pda-validation-check",[926],{"type":52,"value":927},"Step 3: PDA Validation Check",{"type":47,"tag":149,"props":929,"children":931},{"className":804,"code":930,"language":806,"meta":154,"style":154},"# 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",[932],{"type":47,"tag":136,"props":933,"children":934},{"__ignoreMap":154},[935,943,967,991,998,1006],{"type":47,"tag":160,"props":936,"children":937},{"class":162,"line":163},[938],{"type":47,"tag":160,"props":939,"children":940},{"style":816},[941],{"type":52,"value":942},"# Find PDA usage\n",{"type":47,"tag":160,"props":944,"children":945},{"class":162,"line":172},[946,950,954,959,963],{"type":47,"tag":160,"props":947,"children":948},{"style":825},[949],{"type":52,"value":828},{"type":47,"tag":160,"props":951,"children":952},{"style":831},[953],{"type":52,"value":834},{"type":47,"tag":160,"props":955,"children":956},{"style":837},[957],{"type":52,"value":958},"find_program_address|create_program_address",{"type":47,"tag":160,"props":960,"children":961},{"style":831},[962],{"type":52,"value":845},{"type":47,"tag":160,"props":964,"children":965},{"style":837},[966],{"type":52,"value":850},{"type":47,"tag":160,"props":968,"children":969},{"class":162,"line":181},[970,974,978,983,987],{"type":47,"tag":160,"props":971,"children":972},{"style":825},[973],{"type":52,"value":828},{"type":47,"tag":160,"props":975,"children":976},{"style":831},[977],{"type":52,"value":834},{"type":47,"tag":160,"props":979,"children":980},{"style":837},[981],{"type":52,"value":982},"seeds.*bump",{"type":47,"tag":160,"props":984,"children":985},{"style":831},[986],{"type":52,"value":845},{"type":47,"tag":160,"props":988,"children":989},{"style":837},[990],{"type":52,"value":850},{"type":47,"tag":160,"props":992,"children":993},{"class":162,"line":190},[994],{"type":47,"tag":160,"props":995,"children":996},{"emptyLinePlaceholder":248},[997],{"type":52,"value":251},{"type":47,"tag":160,"props":999,"children":1000},{"class":162,"line":199},[1001],{"type":47,"tag":160,"props":1002,"children":1003},{"style":816},[1004],{"type":52,"value":1005},"# Anchor: Check for seeds constraints\n",{"type":47,"tag":160,"props":1007,"children":1008},{"class":162,"line":208},[1009,1013,1017,1022,1026],{"type":47,"tag":160,"props":1010,"children":1011},{"style":825},[1012],{"type":52,"value":828},{"type":47,"tag":160,"props":1014,"children":1015},{"style":831},[1016],{"type":52,"value":834},{"type":47,"tag":160,"props":1018,"children":1019},{"style":837},[1020],{"type":52,"value":1021},"#\\[account.*seeds",{"type":47,"tag":160,"props":1023,"children":1024},{"style":831},[1025],{"type":52,"value":845},{"type":47,"tag":160,"props":1027,"children":1028},{"style":837},[1029],{"type":52,"value":850},{"type":47,"tag":62,"props":1031,"children":1032},{},[1033],{"type":52,"value":1034},"For each PDA:",{"type":47,"tag":74,"props":1036,"children":1038},{"className":1037},[882],[1039,1064,1073],{"type":47,"tag":78,"props":1040,"children":1042},{"className":1041},[887],[1043,1046,1048,1054,1056,1062],{"type":47,"tag":890,"props":1044,"children":1045},{"disabled":248,"type":892},[],{"type":52,"value":1047}," Uses ",{"type":47,"tag":136,"props":1049,"children":1051},{"className":1050},[],[1052],{"type":52,"value":1053},"find_program_address()",{"type":52,"value":1055}," or Anchor ",{"type":47,"tag":136,"props":1057,"children":1059},{"className":1058},[],[1060],{"type":52,"value":1061},"seeds",{"type":52,"value":1063}," constraint",{"type":47,"tag":78,"props":1065,"children":1067},{"className":1066},[887],[1068,1071],{"type":47,"tag":890,"props":1069,"children":1070},{"disabled":248,"type":892},[],{"type":52,"value":1072}," Bump seed stored and reused",{"type":47,"tag":78,"props":1074,"children":1076},{"className":1075},[887],[1077,1080],{"type":47,"tag":890,"props":1078,"children":1079},{"disabled":248,"type":892},[],{"type":52,"value":1081}," Not using user-provided bump",{"type":47,"tag":115,"props":1083,"children":1085},{"id":1084},"step-4-account-validation-sweep",[1086],{"type":52,"value":1087},"Step 4: Account Validation Sweep",{"type":47,"tag":149,"props":1089,"children":1091},{"className":804,"code":1090,"language":806,"meta":154,"style":154},"# 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",[1092],{"type":47,"tag":136,"props":1093,"children":1094},{"__ignoreMap":154},[1095,1103,1127,1134,1142],{"type":47,"tag":160,"props":1096,"children":1097},{"class":162,"line":163},[1098],{"type":47,"tag":160,"props":1099,"children":1100},{"style":816},[1101],{"type":52,"value":1102},"# Find account deserialization\n",{"type":47,"tag":160,"props":1104,"children":1105},{"class":162,"line":172},[1106,1110,1114,1119,1123],{"type":47,"tag":160,"props":1107,"children":1108},{"style":825},[1109],{"type":52,"value":828},{"type":47,"tag":160,"props":1111,"children":1112},{"style":831},[1113],{"type":52,"value":834},{"type":47,"tag":160,"props":1115,"children":1116},{"style":837},[1117],{"type":52,"value":1118},"try_from_slice|try_deserialize",{"type":47,"tag":160,"props":1120,"children":1121},{"style":831},[1122],{"type":52,"value":845},{"type":47,"tag":160,"props":1124,"children":1125},{"style":837},[1126],{"type":52,"value":850},{"type":47,"tag":160,"props":1128,"children":1129},{"class":162,"line":181},[1130],{"type":47,"tag":160,"props":1131,"children":1132},{"emptyLinePlaceholder":248},[1133],{"type":52,"value":251},{"type":47,"tag":160,"props":1135,"children":1136},{"class":162,"line":190},[1137],{"type":47,"tag":160,"props":1138,"children":1139},{"style":816},[1140],{"type":52,"value":1141},"# Should see owner checks before deserialization\n",{"type":47,"tag":160,"props":1143,"children":1144},{"class":162,"line":199},[1145,1149,1153,1158,1162],{"type":47,"tag":160,"props":1146,"children":1147},{"style":825},[1148],{"type":52,"value":828},{"type":47,"tag":160,"props":1150,"children":1151},{"style":831},[1152],{"type":52,"value":834},{"type":47,"tag":160,"props":1154,"children":1155},{"style":837},[1156],{"type":52,"value":1157},"\\.owner\\s*==|\\.owner\\s*!=",{"type":47,"tag":160,"props":1159,"children":1160},{"style":831},[1161],{"type":52,"value":845},{"type":47,"tag":160,"props":1163,"children":1164},{"style":837},[1165],{"type":52,"value":850},{"type":47,"tag":62,"props":1167,"children":1168},{},[1169],{"type":52,"value":1170},"For each account used:",{"type":47,"tag":74,"props":1172,"children":1174},{"className":1173},[882],[1175,1184,1193],{"type":47,"tag":78,"props":1176,"children":1178},{"className":1177},[887],[1179,1182],{"type":47,"tag":890,"props":1180,"children":1181},{"disabled":248,"type":892},[],{"type":52,"value":1183}," Owner validated before deserialization",{"type":47,"tag":78,"props":1185,"children":1187},{"className":1186},[887],[1188,1191],{"type":47,"tag":890,"props":1189,"children":1190},{"disabled":248,"type":892},[],{"type":52,"value":1192}," Signer check for authority accounts",{"type":47,"tag":78,"props":1194,"children":1196},{"className":1195},[887],[1197,1200,1201,1207,1209],{"type":47,"tag":890,"props":1198,"children":1199},{"disabled":248,"type":892},[],{"type":52,"value":913},{"type":47,"tag":136,"props":1202,"children":1204},{"className":1203},[],[1205],{"type":52,"value":1206},"Account\u003C'info, T>",{"type":52,"value":1208}," and ",{"type":47,"tag":136,"props":1210,"children":1212},{"className":1211},[],[1213],{"type":52,"value":1214},"Signer\u003C'info>",{"type":47,"tag":115,"props":1216,"children":1218},{"id":1217},"step-5-instruction-introspection-review",[1219],{"type":52,"value":1220},"Step 5: Instruction Introspection Review",{"type":47,"tag":149,"props":1222,"children":1224},{"className":804,"code":1223,"language":806,"meta":154,"style":154},"# 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",[1225],{"type":47,"tag":136,"props":1226,"children":1227},{"__ignoreMap":154},[1228,1236,1260,1267,1275],{"type":47,"tag":160,"props":1229,"children":1230},{"class":162,"line":163},[1231],{"type":47,"tag":160,"props":1232,"children":1233},{"style":816},[1234],{"type":52,"value":1235},"# Find instruction introspection usage\n",{"type":47,"tag":160,"props":1237,"children":1238},{"class":162,"line":172},[1239,1243,1247,1252,1256],{"type":47,"tag":160,"props":1240,"children":1241},{"style":825},[1242],{"type":52,"value":828},{"type":47,"tag":160,"props":1244,"children":1245},{"style":831},[1246],{"type":52,"value":834},{"type":47,"tag":160,"props":1248,"children":1249},{"style":837},[1250],{"type":52,"value":1251},"load_instruction_at|load_current_index|get_instruction_relative",{"type":47,"tag":160,"props":1253,"children":1254},{"style":831},[1255],{"type":52,"value":845},{"type":47,"tag":160,"props":1257,"children":1258},{"style":837},[1259],{"type":52,"value":850},{"type":47,"tag":160,"props":1261,"children":1262},{"class":162,"line":181},[1263],{"type":47,"tag":160,"props":1264,"children":1265},{"emptyLinePlaceholder":248},[1266],{"type":52,"value":251},{"type":47,"tag":160,"props":1268,"children":1269},{"class":162,"line":190},[1270],{"type":47,"tag":160,"props":1271,"children":1272},{"style":816},[1273],{"type":52,"value":1274},"# Check for checked versions\n",{"type":47,"tag":160,"props":1276,"children":1277},{"class":162,"line":199},[1278,1282,1286,1291,1295],{"type":47,"tag":160,"props":1279,"children":1280},{"style":825},[1281],{"type":52,"value":828},{"type":47,"tag":160,"props":1283,"children":1284},{"style":831},[1285],{"type":52,"value":834},{"type":47,"tag":160,"props":1287,"children":1288},{"style":837},[1289],{"type":52,"value":1290},"load_instruction_at_checked|load_current_index_checked",{"type":47,"tag":160,"props":1292,"children":1293},{"style":831},[1294],{"type":52,"value":845},{"type":47,"tag":160,"props":1296,"children":1297},{"style":837},[1298],{"type":52,"value":850},{"type":47,"tag":74,"props":1300,"children":1302},{"className":1301},[882],[1303,1312,1321],{"type":47,"tag":78,"props":1304,"children":1306},{"className":1305},[887],[1307,1310],{"type":47,"tag":890,"props":1308,"children":1309},{"disabled":248,"type":892},[],{"type":52,"value":1311}," Using checked functions (Solana 1.8.1+)",{"type":47,"tag":78,"props":1313,"children":1315},{"className":1314},[887],[1316,1319],{"type":47,"tag":890,"props":1317,"children":1318},{"disabled":248,"type":892},[],{"type":52,"value":1320}," Using relative indexing",{"type":47,"tag":78,"props":1322,"children":1324},{"className":1323},[887],[1325,1328],{"type":47,"tag":890,"props":1326,"children":1327},{"disabled":248,"type":892},[],{"type":52,"value":1329}," Proper correlation validation",{"type":47,"tag":115,"props":1331,"children":1333},{"id":1332},"step-6-trail-of-bits-solana-lints",[1334],{"type":52,"value":1335},"Step 6: Trail of Bits Solana Lints",{"type":47,"tag":149,"props":1337,"children":1341},{"className":1338,"code":1339,"language":1340,"meta":154,"style":154},"language-toml shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","# 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","toml",[1342],{"type":47,"tag":136,"props":1343,"children":1344},{"__ignoreMap":154},[1345,1353,1361,1369,1376,1384,1392],{"type":47,"tag":160,"props":1346,"children":1347},{"class":162,"line":163},[1348],{"type":47,"tag":160,"props":1349,"children":1350},{},[1351],{"type":52,"value":1352},"# Add to Cargo.toml\n",{"type":47,"tag":160,"props":1354,"children":1355},{"class":162,"line":172},[1356],{"type":47,"tag":160,"props":1357,"children":1358},{},[1359],{"type":52,"value":1360},"[dependencies]\n",{"type":47,"tag":160,"props":1362,"children":1363},{"class":162,"line":181},[1364],{"type":47,"tag":160,"props":1365,"children":1366},{},[1367],{"type":52,"value":1368},"solana-program = \"1.17\"  # Use latest version\n",{"type":47,"tag":160,"props":1370,"children":1371},{"class":162,"line":190},[1372],{"type":47,"tag":160,"props":1373,"children":1374},{"emptyLinePlaceholder":248},[1375],{"type":52,"value":251},{"type":47,"tag":160,"props":1377,"children":1378},{"class":162,"line":199},[1379],{"type":47,"tag":160,"props":1380,"children":1381},{},[1382],{"type":52,"value":1383},"[lints.clippy]\n",{"type":47,"tag":160,"props":1385,"children":1386},{"class":162,"line":208},[1387],{"type":47,"tag":160,"props":1388,"children":1389},{},[1390],{"type":52,"value":1391},"# Enable Solana-specific lints\n",{"type":47,"tag":160,"props":1393,"children":1394},{"class":162,"line":217},[1395],{"type":47,"tag":160,"props":1396,"children":1397},{},[1398],{"type":52,"value":1399},"# (Trail of Bits solana-lints if available)\n",{"type":47,"tag":575,"props":1401,"children":1402},{},[],{"type":47,"tag":55,"props":1404,"children":1406},{"id":1405},"_8-reporting-format",[1407],{"type":52,"value":1408},"8. Reporting Format",{"type":47,"tag":115,"props":1410,"children":1412},{"id":1411},"finding-template",[1413],{"type":52,"value":1414},"Finding Template",{"type":47,"tag":149,"props":1416,"children":1420},{"className":1417,"code":1418,"language":1419,"meta":154,"style":154},"language-markdown shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","## [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","markdown",[1421],{"type":47,"tag":136,"props":1422,"children":1423},{"__ignoreMap":154},[1424,1447,1454,1497,1504,1525,1569,1576,1596,1610,1618,1626,1634,1641,1649,1657,1665,1673,1681,1689,1697,1705,1713,1721,1729],{"type":47,"tag":160,"props":1425,"children":1426},{"class":162,"line":163},[1427,1432,1437,1442],{"type":47,"tag":160,"props":1428,"children":1429},{"style":831},[1430],{"type":52,"value":1431},"## [",{"type":47,"tag":160,"props":1433,"children":1434},{"style":837},[1435],{"type":52,"value":1436},"CRITICAL",{"type":47,"tag":160,"props":1438,"children":1439},{"style":831},[1440],{"type":52,"value":1441},"]",{"type":47,"tag":160,"props":1443,"children":1444},{"style":825},[1445],{"type":52,"value":1446}," Arbitrary CPI - Unchecked Program ID\n",{"type":47,"tag":160,"props":1448,"children":1449},{"class":162,"line":172},[1450],{"type":47,"tag":160,"props":1451,"children":1452},{"emptyLinePlaceholder":248},[1453],{"type":52,"value":251},{"type":47,"tag":160,"props":1455,"children":1456},{"class":162,"line":181},[1457,1463,1469,1473,1478,1483,1488,1492],{"type":47,"tag":160,"props":1458,"children":1460},{"style":1459},"--shiki-light:#39ADB5;--shiki-light-font-weight:bold;--shiki-default:#89DDFF;--shiki-default-font-weight:bold;--shiki-dark:#89DDFF;--shiki-dark-font-weight:bold",[1461],{"type":52,"value":1462},"**",{"type":47,"tag":160,"props":1464,"children":1466},{"style":1465},"--shiki-light:#E53935;--shiki-light-font-weight:bold;--shiki-default:#F07178;--shiki-default-font-weight:bold;--shiki-dark:#F07178;--shiki-dark-font-weight:bold",[1467],{"type":52,"value":1468},"Location",{"type":47,"tag":160,"props":1470,"children":1471},{"style":1459},[1472],{"type":52,"value":1462},{"type":47,"tag":160,"props":1474,"children":1476},{"style":1475},"--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8",[1477],{"type":52,"value":134},{"type":47,"tag":160,"props":1479,"children":1480},{"style":831},[1481],{"type":52,"value":1482},"`",{"type":47,"tag":160,"props":1484,"children":1485},{"style":837},[1486],{"type":52,"value":1487},"programs\u002Fvault\u002Fsrc\u002Flib.rs:145-160",{"type":47,"tag":160,"props":1489,"children":1490},{"style":831},[1491],{"type":52,"value":1482},{"type":47,"tag":160,"props":1493,"children":1494},{"style":1475},[1495],{"type":52,"value":1496}," (withdraw function)\n",{"type":47,"tag":160,"props":1498,"children":1499},{"class":162,"line":190},[1500],{"type":47,"tag":160,"props":1501,"children":1502},{"emptyLinePlaceholder":248},[1503],{"type":52,"value":251},{"type":47,"tag":160,"props":1505,"children":1506},{"class":162,"line":199},[1507,1511,1516,1520],{"type":47,"tag":160,"props":1508,"children":1509},{"style":1459},[1510],{"type":52,"value":1462},{"type":47,"tag":160,"props":1512,"children":1513},{"style":1465},[1514],{"type":52,"value":1515},"Description",{"type":47,"tag":160,"props":1517,"children":1518},{"style":1459},[1519],{"type":52,"value":1462},{"type":47,"tag":160,"props":1521,"children":1522},{"style":1475},[1523],{"type":52,"value":1524},":\n",{"type":47,"tag":160,"props":1526,"children":1527},{"class":162,"line":208},[1528,1533,1537,1542,1546,1551,1555,1560,1564],{"type":47,"tag":160,"props":1529,"children":1530},{"style":1475},[1531],{"type":52,"value":1532},"The ",{"type":47,"tag":160,"props":1534,"children":1535},{"style":831},[1536],{"type":52,"value":1482},{"type":47,"tag":160,"props":1538,"children":1539},{"style":837},[1540],{"type":52,"value":1541},"withdraw",{"type":47,"tag":160,"props":1543,"children":1544},{"style":831},[1545],{"type":52,"value":1482},{"type":47,"tag":160,"props":1547,"children":1548},{"style":1475},[1549],{"type":52,"value":1550}," function performs a CPI to transfer SPL tokens without validating that the provided ",{"type":47,"tag":160,"props":1552,"children":1553},{"style":831},[1554],{"type":52,"value":1482},{"type":47,"tag":160,"props":1556,"children":1557},{"style":837},[1558],{"type":52,"value":1559},"token_program",{"type":47,"tag":160,"props":1561,"children":1562},{"style":831},[1563],{"type":52,"value":1482},{"type":47,"tag":160,"props":1565,"children":1566},{"style":1475},[1567],{"type":52,"value":1568}," 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",{"type":47,"tag":160,"props":1570,"children":1571},{"class":162,"line":217},[1572],{"type":47,"tag":160,"props":1573,"children":1574},{"emptyLinePlaceholder":248},[1575],{"type":52,"value":251},{"type":47,"tag":160,"props":1577,"children":1578},{"class":162,"line":226},[1579,1583,1588,1592],{"type":47,"tag":160,"props":1580,"children":1581},{"style":1459},[1582],{"type":52,"value":1462},{"type":47,"tag":160,"props":1584,"children":1585},{"style":1465},[1586],{"type":52,"value":1587},"Vulnerable Code",{"type":47,"tag":160,"props":1589,"children":1590},{"style":1459},[1591],{"type":52,"value":1462},{"type":47,"tag":160,"props":1593,"children":1594},{"style":1475},[1595],{"type":52,"value":1524},{"type":47,"tag":160,"props":1597,"children":1598},{"class":162,"line":235},[1599,1604],{"type":47,"tag":160,"props":1600,"children":1601},{"style":837},[1602],{"type":52,"value":1603},"```",{"type":47,"tag":160,"props":1605,"children":1607},{"style":1606},"--shiki-light:#90A4AE90;--shiki-default:#EEFFFF90;--shiki-dark:#BABED890",[1608],{"type":52,"value":1609},"rust\n",{"type":47,"tag":160,"props":1611,"children":1612},{"class":162,"line":244},[1613],{"type":47,"tag":160,"props":1614,"children":1615},{"style":1606},[1616],{"type":52,"value":1617},"\u002F\u002F lib.rs, line 145\n",{"type":47,"tag":160,"props":1619,"children":1620},{"class":162,"line":254},[1621],{"type":47,"tag":160,"props":1622,"children":1623},{"style":1606},[1624],{"type":52,"value":1625},"pub fn withdraw(ctx: Context\u003CWithdraw>, amount: u64) -> Result\u003C()> {\n",{"type":47,"tag":160,"props":1627,"children":1628},{"class":162,"line":263},[1629],{"type":47,"tag":160,"props":1630,"children":1631},{"style":1606},[1632],{"type":52,"value":1633},"    let token_program = &ctx.accounts.token_program;\n",{"type":47,"tag":160,"props":1635,"children":1636},{"class":162,"line":271},[1637],{"type":47,"tag":160,"props":1638,"children":1639},{"emptyLinePlaceholder":248},[1640],{"type":52,"value":251},{"type":47,"tag":160,"props":1642,"children":1643},{"class":162,"line":280},[1644],{"type":47,"tag":160,"props":1645,"children":1646},{"style":1606},[1647],{"type":52,"value":1648},"    \u002F\u002F WRONG: No validation of token_program.key()!\n",{"type":47,"tag":160,"props":1650,"children":1651},{"class":162,"line":289},[1652],{"type":47,"tag":160,"props":1653,"children":1654},{"style":1606},[1655],{"type":52,"value":1656},"    invoke(\n",{"type":47,"tag":160,"props":1658,"children":1659},{"class":162,"line":297},[1660],{"type":47,"tag":160,"props":1661,"children":1662},{"style":1606},[1663],{"type":52,"value":1664},"        &spl_token::instruction::transfer(...),\n",{"type":47,"tag":160,"props":1666,"children":1667},{"class":162,"line":306},[1668],{"type":47,"tag":160,"props":1669,"children":1670},{"style":1606},[1671],{"type":52,"value":1672},"        &[\n",{"type":47,"tag":160,"props":1674,"children":1675},{"class":162,"line":315},[1676],{"type":47,"tag":160,"props":1677,"children":1678},{"style":1606},[1679],{"type":52,"value":1680},"            ctx.accounts.vault.to_account_info(),\n",{"type":47,"tag":160,"props":1682,"children":1683},{"class":162,"line":324},[1684],{"type":47,"tag":160,"props":1685,"children":1686},{"style":1606},[1687],{"type":52,"value":1688},"            ctx.accounts.destination.to_account_info(),\n",{"type":47,"tag":160,"props":1690,"children":1691},{"class":162,"line":333},[1692],{"type":47,"tag":160,"props":1693,"children":1694},{"style":1606},[1695],{"type":52,"value":1696},"            ctx.accounts.authority.to_account_info(),\n",{"type":47,"tag":160,"props":1698,"children":1699},{"class":162,"line":342},[1700],{"type":47,"tag":160,"props":1701,"children":1702},{"style":1606},[1703],{"type":52,"value":1704},"            token_program.to_account_info(),  \u002F\u002F UNVALIDATED\n",{"type":47,"tag":160,"props":1706,"children":1707},{"class":162,"line":351},[1708],{"type":47,"tag":160,"props":1709,"children":1710},{"style":1606},[1711],{"type":52,"value":1712},"        ],\n",{"type":47,"tag":160,"props":1714,"children":1715},{"class":162,"line":359},[1716],{"type":47,"tag":160,"props":1717,"children":1718},{"style":1606},[1719],{"type":52,"value":1720},"    )?;\n",{"type":47,"tag":160,"props":1722,"children":1723},{"class":162,"line":368},[1724],{"type":47,"tag":160,"props":1725,"children":1726},{"style":1606},[1727],{"type":52,"value":1728},"    Ok(())\n",{"type":47,"tag":160,"props":1730,"children":1731},{"class":162,"line":377},[1732],{"type":47,"tag":160,"props":1733,"children":1734},{"style":1606},[1735],{"type":52,"value":348},{"type":47,"tag":62,"props":1737,"children":1738},{},[1739,1744],{"type":47,"tag":128,"props":1740,"children":1741},{},[1742],{"type":52,"value":1743},"Attack Scenario",{"type":52,"value":1745},":",{"type":47,"tag":590,"props":1747,"children":1748},{},[1749,1754,1759,1764,1769],{"type":47,"tag":78,"props":1750,"children":1751},{},[1752],{"type":52,"value":1753},"Attacker deploys malicious \"token program\" that logs transfer instruction but doesn't execute it",{"type":47,"tag":78,"props":1755,"children":1756},{},[1757],{"type":52,"value":1758},"Attacker calls withdraw() providing malicious program as token_program",{"type":47,"tag":78,"props":1760,"children":1761},{},[1762],{"type":52,"value":1763},"Vault's authority signs the transaction",{"type":47,"tag":78,"props":1765,"children":1766},{},[1767],{"type":52,"value":1768},"Malicious program receives CPI with vault's signature",{"type":47,"tag":78,"props":1770,"children":1771},{},[1772],{"type":52,"value":1773},"Malicious program can now impersonate vault and drain real tokens",{"type":47,"tag":62,"props":1775,"children":1776},{},[1777,1782,1784,1790],{"type":47,"tag":128,"props":1778,"children":1779},{},[1780],{"type":52,"value":1781},"Recommendation",{"type":52,"value":1783},":\nUse Anchor's ",{"type":47,"tag":136,"props":1785,"children":1787},{"className":1786},[],[1788],{"type":52,"value":1789},"Program\u003C'info, Token>",{"type":52,"value":1791}," type:",{"type":47,"tag":149,"props":1793,"children":1795},{"className":151,"code":1794,"language":153,"meta":154,"style":154},"use 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",[1796],{"type":47,"tag":136,"props":1797,"children":1798},{"__ignoreMap":154},[1799,1807,1814,1821,1829,1836,1844,1851,1859,1866,1874,1881,1888,1895,1903,1911,1919,1927,1935,1942,1950,1958,1966,1974,1981,1989,1996],{"type":47,"tag":160,"props":1800,"children":1801},{"class":162,"line":163},[1802],{"type":47,"tag":160,"props":1803,"children":1804},{},[1805],{"type":52,"value":1806},"use anchor_spl::token::{Token, Transfer};\n",{"type":47,"tag":160,"props":1808,"children":1809},{"class":162,"line":172},[1810],{"type":47,"tag":160,"props":1811,"children":1812},{"emptyLinePlaceholder":248},[1813],{"type":52,"value":251},{"type":47,"tag":160,"props":1815,"children":1816},{"class":162,"line":181},[1817],{"type":47,"tag":160,"props":1818,"children":1819},{},[1820],{"type":52,"value":365},{"type":47,"tag":160,"props":1822,"children":1823},{"class":162,"line":190},[1824],{"type":47,"tag":160,"props":1825,"children":1826},{},[1827],{"type":52,"value":1828},"pub struct Withdraw\u003C'info> {\n",{"type":47,"tag":160,"props":1830,"children":1831},{"class":162,"line":199},[1832],{"type":47,"tag":160,"props":1833,"children":1834},{},[1835],{"type":52,"value":383},{"type":47,"tag":160,"props":1837,"children":1838},{"class":162,"line":208},[1839],{"type":47,"tag":160,"props":1840,"children":1841},{},[1842],{"type":52,"value":1843},"    pub vault: Account\u003C'info, TokenAccount>,\n",{"type":47,"tag":160,"props":1845,"children":1846},{"class":162,"line":217},[1847],{"type":47,"tag":160,"props":1848,"children":1849},{},[1850],{"type":52,"value":383},{"type":47,"tag":160,"props":1852,"children":1853},{"class":162,"line":226},[1854],{"type":47,"tag":160,"props":1855,"children":1856},{},[1857],{"type":52,"value":1858},"    pub destination: Account\u003C'info, TokenAccount>,\n",{"type":47,"tag":160,"props":1860,"children":1861},{"class":162,"line":235},[1862],{"type":47,"tag":160,"props":1863,"children":1864},{},[1865],{"type":52,"value":392},{"type":47,"tag":160,"props":1867,"children":1868},{"class":162,"line":244},[1869],{"type":47,"tag":160,"props":1870,"children":1871},{},[1872],{"type":52,"value":1873},"    pub token_program: Program\u003C'info, Token>,  \u002F\u002F Validates program ID automatically\n",{"type":47,"tag":160,"props":1875,"children":1876},{"class":162,"line":254},[1877],{"type":47,"tag":160,"props":1878,"children":1879},{},[1880],{"type":52,"value":348},{"type":47,"tag":160,"props":1882,"children":1883},{"class":162,"line":263},[1884],{"type":47,"tag":160,"props":1885,"children":1886},{"emptyLinePlaceholder":248},[1887],{"type":52,"value":251},{"type":47,"tag":160,"props":1889,"children":1890},{"class":162,"line":271},[1891],{"type":47,"tag":160,"props":1892,"children":1893},{},[1894],{"type":52,"value":1625},{"type":47,"tag":160,"props":1896,"children":1897},{"class":162,"line":280},[1898],{"type":47,"tag":160,"props":1899,"children":1900},{},[1901],{"type":52,"value":1902},"    let cpi_accounts = Transfer {\n",{"type":47,"tag":160,"props":1904,"children":1905},{"class":162,"line":289},[1906],{"type":47,"tag":160,"props":1907,"children":1908},{},[1909],{"type":52,"value":1910},"        from: ctx.accounts.vault.to_account_info(),\n",{"type":47,"tag":160,"props":1912,"children":1913},{"class":162,"line":297},[1914],{"type":47,"tag":160,"props":1915,"children":1916},{},[1917],{"type":52,"value":1918},"        to: ctx.accounts.destination.to_account_info(),\n",{"type":47,"tag":160,"props":1920,"children":1921},{"class":162,"line":306},[1922],{"type":47,"tag":160,"props":1923,"children":1924},{},[1925],{"type":52,"value":1926},"        authority: ctx.accounts.authority.to_account_info(),\n",{"type":47,"tag":160,"props":1928,"children":1929},{"class":162,"line":315},[1930],{"type":47,"tag":160,"props":1931,"children":1932},{},[1933],{"type":52,"value":1934},"    };\n",{"type":47,"tag":160,"props":1936,"children":1937},{"class":162,"line":324},[1938],{"type":47,"tag":160,"props":1939,"children":1940},{"emptyLinePlaceholder":248},[1941],{"type":52,"value":251},{"type":47,"tag":160,"props":1943,"children":1944},{"class":162,"line":333},[1945],{"type":47,"tag":160,"props":1946,"children":1947},{},[1948],{"type":52,"value":1949},"    let cpi_ctx = CpiContext::new(\n",{"type":47,"tag":160,"props":1951,"children":1952},{"class":162,"line":342},[1953],{"type":47,"tag":160,"props":1954,"children":1955},{},[1956],{"type":52,"value":1957},"        ctx.accounts.token_program.to_account_info(),\n",{"type":47,"tag":160,"props":1959,"children":1960},{"class":162,"line":351},[1961],{"type":47,"tag":160,"props":1962,"children":1963},{},[1964],{"type":52,"value":1965},"        cpi_accounts,\n",{"type":47,"tag":160,"props":1967,"children":1968},{"class":162,"line":359},[1969],{"type":47,"tag":160,"props":1970,"children":1971},{},[1972],{"type":52,"value":1973},"    );\n",{"type":47,"tag":160,"props":1975,"children":1976},{"class":162,"line":368},[1977],{"type":47,"tag":160,"props":1978,"children":1979},{"emptyLinePlaceholder":248},[1980],{"type":52,"value":251},{"type":47,"tag":160,"props":1982,"children":1983},{"class":162,"line":377},[1984],{"type":47,"tag":160,"props":1985,"children":1986},{},[1987],{"type":52,"value":1988},"    anchor_spl::token::transfer(cpi_ctx, amount)?;\n",{"type":47,"tag":160,"props":1990,"children":1991},{"class":162,"line":386},[1992],{"type":47,"tag":160,"props":1993,"children":1994},{},[1995],{"type":52,"value":1728},{"type":47,"tag":160,"props":1997,"children":1998},{"class":162,"line":395},[1999],{"type":47,"tag":160,"props":2000,"children":2001},{},[2002],{"type":52,"value":348},{"type":47,"tag":62,"props":2004,"children":2005},{},[2006,2011],{"type":47,"tag":128,"props":2007,"children":2008},{},[2009],{"type":52,"value":2010},"References",{"type":52,"value":1745},{"type":47,"tag":74,"props":2013,"children":2014},{},[2015,2020],{"type":47,"tag":78,"props":2016,"children":2017},{},[2018],{"type":52,"value":2019},"building-secure-contracts\u002Fnot-so-smart-contracts\u002Fsolana\u002Farbitrary_cpi",{"type":47,"tag":78,"props":2021,"children":2022},{},[2023,2025],{"type":52,"value":2024},"Trail of Bits lint: ",{"type":47,"tag":136,"props":2026,"children":2028},{"className":2027},[],[2029],{"type":52,"value":2030},"unchecked-cpi-program-id",{"type":47,"tag":149,"props":2032,"children":2036},{"className":2033,"code":2035,"language":52},[2034],"language-text","\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",[2037],{"type":47,"tag":136,"props":2038,"children":2039},{"__ignoreMap":154},[2040],{"type":52,"value":2035},{"type":47,"tag":115,"props":2042,"children":2044},{"id":2043},"integration-tests-anchor",[2045],{"type":52,"value":2046},"Integration Tests (Anchor)",{"type":47,"tag":149,"props":2048,"children":2052},{"className":2049,"code":2050,"language":2051,"meta":154,"style":154},"language-typescript shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import * 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","typescript",[2053],{"type":47,"tag":136,"props":2054,"children":2055},{"__ignoreMap":154},[2056,2103,2110,2158,2205,2264,2271,2283,2305,2331,2352,2386,2398,2418,2425,2467,2499,2507,2514,2530],{"type":47,"tag":160,"props":2057,"children":2058},{"class":162,"line":163},[2059,2065,2070,2075,2080,2085,2089,2094,2098],{"type":47,"tag":160,"props":2060,"children":2062},{"style":2061},"--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic",[2063],{"type":52,"value":2064},"import",{"type":47,"tag":160,"props":2066,"children":2067},{"style":831},[2068],{"type":52,"value":2069}," *",{"type":47,"tag":160,"props":2071,"children":2072},{"style":2061},[2073],{"type":52,"value":2074}," as",{"type":47,"tag":160,"props":2076,"children":2077},{"style":1475},[2078],{"type":52,"value":2079}," anchor ",{"type":47,"tag":160,"props":2081,"children":2082},{"style":2061},[2083],{"type":52,"value":2084},"from",{"type":47,"tag":160,"props":2086,"children":2087},{"style":831},[2088],{"type":52,"value":834},{"type":47,"tag":160,"props":2090,"children":2091},{"style":837},[2092],{"type":52,"value":2093},"@coral-xyz\u002Fanchor",{"type":47,"tag":160,"props":2095,"children":2096},{"style":831},[2097],{"type":52,"value":845},{"type":47,"tag":160,"props":2099,"children":2100},{"style":831},[2101],{"type":52,"value":2102},";\n",{"type":47,"tag":160,"props":2104,"children":2105},{"class":162,"line":172},[2106],{"type":47,"tag":160,"props":2107,"children":2108},{"emptyLinePlaceholder":248},[2109],{"type":52,"value":251},{"type":47,"tag":160,"props":2111,"children":2112},{"class":162,"line":181},[2113,2119,2124,2128,2133,2137,2142,2147,2153],{"type":47,"tag":160,"props":2114,"children":2116},{"style":2115},"--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF",[2117],{"type":52,"value":2118},"describe",{"type":47,"tag":160,"props":2120,"children":2121},{"style":1475},[2122],{"type":52,"value":2123},"(",{"type":47,"tag":160,"props":2125,"children":2126},{"style":831},[2127],{"type":52,"value":845},{"type":47,"tag":160,"props":2129,"children":2130},{"style":837},[2131],{"type":52,"value":2132},"security tests",{"type":47,"tag":160,"props":2134,"children":2135},{"style":831},[2136],{"type":52,"value":845},{"type":47,"tag":160,"props":2138,"children":2139},{"style":831},[2140],{"type":52,"value":2141},",",{"type":47,"tag":160,"props":2143,"children":2144},{"style":831},[2145],{"type":52,"value":2146}," ()",{"type":47,"tag":160,"props":2148,"children":2150},{"style":2149},"--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA",[2151],{"type":52,"value":2152}," =>",{"type":47,"tag":160,"props":2154,"children":2155},{"style":831},[2156],{"type":52,"value":2157}," {\n",{"type":47,"tag":160,"props":2159,"children":2160},{"class":162,"line":190},[2161,2166,2171,2175,2180,2184,2188,2193,2197,2201],{"type":47,"tag":160,"props":2162,"children":2163},{"style":2115},[2164],{"type":52,"value":2165},"  it",{"type":47,"tag":160,"props":2167,"children":2169},{"style":2168},"--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178",[2170],{"type":52,"value":2123},{"type":47,"tag":160,"props":2172,"children":2173},{"style":831},[2174],{"type":52,"value":845},{"type":47,"tag":160,"props":2176,"children":2177},{"style":837},[2178],{"type":52,"value":2179},"rejects arbitrary CPI",{"type":47,"tag":160,"props":2181,"children":2182},{"style":831},[2183],{"type":52,"value":845},{"type":47,"tag":160,"props":2185,"children":2186},{"style":831},[2187],{"type":52,"value":2141},{"type":47,"tag":160,"props":2189,"children":2190},{"style":2149},[2191],{"type":52,"value":2192}," async",{"type":47,"tag":160,"props":2194,"children":2195},{"style":831},[2196],{"type":52,"value":2146},{"type":47,"tag":160,"props":2198,"children":2199},{"style":2149},[2200],{"type":52,"value":2152},{"type":47,"tag":160,"props":2202,"children":2203},{"style":831},[2204],{"type":52,"value":2157},{"type":47,"tag":160,"props":2206,"children":2207},{"class":162,"line":199},[2208,2213,2218,2223,2228,2232,2237,2241,2246,2250,2255,2260],{"type":47,"tag":160,"props":2209,"children":2210},{"style":2149},[2211],{"type":52,"value":2212},"    const",{"type":47,"tag":160,"props":2214,"children":2215},{"style":1475},[2216],{"type":52,"value":2217}," fakeTokenProgram",{"type":47,"tag":160,"props":2219,"children":2220},{"style":831},[2221],{"type":52,"value":2222}," =",{"type":47,"tag":160,"props":2224,"children":2225},{"style":1475},[2226],{"type":52,"value":2227}," anchor",{"type":47,"tag":160,"props":2229,"children":2230},{"style":831},[2231],{"type":52,"value":674},{"type":47,"tag":160,"props":2233,"children":2234},{"style":1475},[2235],{"type":52,"value":2236},"web3",{"type":47,"tag":160,"props":2238,"children":2239},{"style":831},[2240],{"type":52,"value":674},{"type":47,"tag":160,"props":2242,"children":2243},{"style":1475},[2244],{"type":52,"value":2245},"Keypair",{"type":47,"tag":160,"props":2247,"children":2248},{"style":831},[2249],{"type":52,"value":674},{"type":47,"tag":160,"props":2251,"children":2252},{"style":2115},[2253],{"type":52,"value":2254},"generate",{"type":47,"tag":160,"props":2256,"children":2257},{"style":2168},[2258],{"type":52,"value":2259},"()",{"type":47,"tag":160,"props":2261,"children":2262},{"style":831},[2263],{"type":52,"value":2102},{"type":47,"tag":160,"props":2265,"children":2266},{"class":162,"line":208},[2267],{"type":47,"tag":160,"props":2268,"children":2269},{"emptyLinePlaceholder":248},[2270],{"type":52,"value":251},{"type":47,"tag":160,"props":2272,"children":2273},{"class":162,"line":217},[2274,2279],{"type":47,"tag":160,"props":2275,"children":2276},{"style":2061},[2277],{"type":52,"value":2278},"    try",{"type":47,"tag":160,"props":2280,"children":2281},{"style":831},[2282],{"type":52,"value":2157},{"type":47,"tag":160,"props":2284,"children":2285},{"class":162,"line":226},[2286,2291,2296,2300],{"type":47,"tag":160,"props":2287,"children":2288},{"style":2061},[2289],{"type":52,"value":2290},"      await",{"type":47,"tag":160,"props":2292,"children":2293},{"style":1475},[2294],{"type":52,"value":2295}," program",{"type":47,"tag":160,"props":2297,"children":2298},{"style":831},[2299],{"type":52,"value":674},{"type":47,"tag":160,"props":2301,"children":2302},{"style":1475},[2303],{"type":52,"value":2304},"methods\n",{"type":47,"tag":160,"props":2306,"children":2307},{"class":162,"line":235},[2308,2313,2317,2321,2326],{"type":47,"tag":160,"props":2309,"children":2310},{"style":831},[2311],{"type":52,"value":2312},"        .",{"type":47,"tag":160,"props":2314,"children":2315},{"style":2115},[2316],{"type":52,"value":1541},{"type":47,"tag":160,"props":2318,"children":2319},{"style":2168},[2320],{"type":52,"value":2123},{"type":47,"tag":160,"props":2322,"children":2323},{"style":1475},[2324],{"type":52,"value":2325},"amount",{"type":47,"tag":160,"props":2327,"children":2328},{"style":2168},[2329],{"type":52,"value":2330},")\n",{"type":47,"tag":160,"props":2332,"children":2333},{"class":162,"line":244},[2334,2338,2343,2347],{"type":47,"tag":160,"props":2335,"children":2336},{"style":831},[2337],{"type":52,"value":2312},{"type":47,"tag":160,"props":2339,"children":2340},{"style":2115},[2341],{"type":52,"value":2342},"accounts",{"type":47,"tag":160,"props":2344,"children":2345},{"style":2168},[2346],{"type":52,"value":2123},{"type":47,"tag":160,"props":2348,"children":2349},{"style":831},[2350],{"type":52,"value":2351},"{\n",{"type":47,"tag":160,"props":2353,"children":2354},{"class":162,"line":254},[2355,2360,2364,2368,2372,2377,2381],{"type":47,"tag":160,"props":2356,"children":2357},{"style":2168},[2358],{"type":52,"value":2359},"          tokenProgram",{"type":47,"tag":160,"props":2361,"children":2362},{"style":831},[2363],{"type":52,"value":1745},{"type":47,"tag":160,"props":2365,"children":2366},{"style":1475},[2367],{"type":52,"value":2217},{"type":47,"tag":160,"props":2369,"children":2370},{"style":831},[2371],{"type":52,"value":674},{"type":47,"tag":160,"props":2373,"children":2374},{"style":1475},[2375],{"type":52,"value":2376},"publicKey",{"type":47,"tag":160,"props":2378,"children":2379},{"style":831},[2380],{"type":52,"value":2141},{"type":47,"tag":160,"props":2382,"children":2383},{"style":816},[2384],{"type":52,"value":2385}," \u002F\u002F Wrong program\n",{"type":47,"tag":160,"props":2387,"children":2388},{"class":162,"line":263},[2389,2394],{"type":47,"tag":160,"props":2390,"children":2391},{"style":831},[2392],{"type":52,"value":2393},"        }",{"type":47,"tag":160,"props":2395,"children":2396},{"style":2168},[2397],{"type":52,"value":2330},{"type":47,"tag":160,"props":2399,"children":2400},{"class":162,"line":271},[2401,2405,2410,2414],{"type":47,"tag":160,"props":2402,"children":2403},{"style":831},[2404],{"type":52,"value":2312},{"type":47,"tag":160,"props":2406,"children":2407},{"style":2115},[2408],{"type":52,"value":2409},"rpc",{"type":47,"tag":160,"props":2411,"children":2412},{"style":2168},[2413],{"type":52,"value":2259},{"type":47,"tag":160,"props":2415,"children":2416},{"style":831},[2417],{"type":52,"value":2102},{"type":47,"tag":160,"props":2419,"children":2420},{"class":162,"line":280},[2421],{"type":47,"tag":160,"props":2422,"children":2423},{"emptyLinePlaceholder":248},[2424],{"type":52,"value":251},{"type":47,"tag":160,"props":2426,"children":2427},{"class":162,"line":289},[2428,2433,2437,2442,2446,2450,2455,2459,2463],{"type":47,"tag":160,"props":2429,"children":2430},{"style":1475},[2431],{"type":52,"value":2432},"      assert",{"type":47,"tag":160,"props":2434,"children":2435},{"style":831},[2436],{"type":52,"value":674},{"type":47,"tag":160,"props":2438,"children":2439},{"style":2115},[2440],{"type":52,"value":2441},"fail",{"type":47,"tag":160,"props":2443,"children":2444},{"style":2168},[2445],{"type":52,"value":2123},{"type":47,"tag":160,"props":2447,"children":2448},{"style":831},[2449],{"type":52,"value":845},{"type":47,"tag":160,"props":2451,"children":2452},{"style":837},[2453],{"type":52,"value":2454},"Should have rejected fake program",{"type":47,"tag":160,"props":2456,"children":2457},{"style":831},[2458],{"type":52,"value":845},{"type":47,"tag":160,"props":2460,"children":2461},{"style":2168},[2462],{"type":52,"value":790},{"type":47,"tag":160,"props":2464,"children":2465},{"style":831},[2466],{"type":52,"value":2102},{"type":47,"tag":160,"props":2468,"children":2469},{"class":162,"line":297},[2470,2475,2480,2485,2490,2495],{"type":47,"tag":160,"props":2471,"children":2472},{"style":831},[2473],{"type":52,"value":2474},"    }",{"type":47,"tag":160,"props":2476,"children":2477},{"style":2061},[2478],{"type":52,"value":2479}," catch",{"type":47,"tag":160,"props":2481,"children":2482},{"style":2168},[2483],{"type":52,"value":2484}," (",{"type":47,"tag":160,"props":2486,"children":2487},{"style":1475},[2488],{"type":52,"value":2489},"err",{"type":47,"tag":160,"props":2491,"children":2492},{"style":2168},[2493],{"type":52,"value":2494},") ",{"type":47,"tag":160,"props":2496,"children":2497},{"style":831},[2498],{"type":52,"value":2351},{"type":47,"tag":160,"props":2500,"children":2501},{"class":162,"line":306},[2502],{"type":47,"tag":160,"props":2503,"children":2504},{"style":816},[2505],{"type":52,"value":2506},"      \u002F\u002F Expected to fail\n",{"type":47,"tag":160,"props":2508,"children":2509},{"class":162,"line":315},[2510],{"type":47,"tag":160,"props":2511,"children":2512},{"style":831},[2513],{"type":52,"value":339},{"type":47,"tag":160,"props":2515,"children":2516},{"class":162,"line":324},[2517,2522,2526],{"type":47,"tag":160,"props":2518,"children":2519},{"style":831},[2520],{"type":52,"value":2521},"  }",{"type":47,"tag":160,"props":2523,"children":2524},{"style":2168},[2525],{"type":52,"value":790},{"type":47,"tag":160,"props":2527,"children":2528},{"style":831},[2529],{"type":52,"value":2102},{"type":47,"tag":160,"props":2531,"children":2532},{"class":162,"line":333},[2533,2538,2542],{"type":47,"tag":160,"props":2534,"children":2535},{"style":831},[2536],{"type":52,"value":2537},"}",{"type":47,"tag":160,"props":2539,"children":2540},{"style":1475},[2541],{"type":52,"value":790},{"type":47,"tag":160,"props":2543,"children":2544},{"style":831},[2545],{"type":52,"value":2102},{"type":47,"tag":115,"props":2547,"children":2549},{"id":2548},"solana-test-validator",[2550],{"type":52,"value":571},{"type":47,"tag":149,"props":2552,"children":2554},{"className":804,"code":2553,"language":806,"meta":154,"style":154},"# Run local validator for testing\nsolana-test-validator\n\n# Deploy and test program\nanchor test\n",[2555],{"type":47,"tag":136,"props":2556,"children":2557},{"__ignoreMap":154},[2558,2566,2574,2581,2589],{"type":47,"tag":160,"props":2559,"children":2560},{"class":162,"line":163},[2561],{"type":47,"tag":160,"props":2562,"children":2563},{"style":816},[2564],{"type":52,"value":2565},"# Run local validator for testing\n",{"type":47,"tag":160,"props":2567,"children":2568},{"class":162,"line":172},[2569],{"type":47,"tag":160,"props":2570,"children":2571},{"style":825},[2572],{"type":52,"value":2573},"solana-test-validator\n",{"type":47,"tag":160,"props":2575,"children":2576},{"class":162,"line":181},[2577],{"type":47,"tag":160,"props":2578,"children":2579},{"emptyLinePlaceholder":248},[2580],{"type":52,"value":251},{"type":47,"tag":160,"props":2582,"children":2583},{"class":162,"line":190},[2584],{"type":47,"tag":160,"props":2585,"children":2586},{"style":816},[2587],{"type":52,"value":2588},"# Deploy and test program\n",{"type":47,"tag":160,"props":2590,"children":2591},{"class":162,"line":199},[2592,2597],{"type":47,"tag":160,"props":2593,"children":2594},{"style":825},[2595],{"type":52,"value":2596},"anchor",{"type":47,"tag":160,"props":2598,"children":2599},{"style":837},[2600],{"type":52,"value":2601}," test\n",{"type":47,"tag":575,"props":2603,"children":2604},{},[],{"type":47,"tag":55,"props":2606,"children":2608},{"id":2607},"_11-additional-resources",[2609],{"type":52,"value":2610},"11. Additional Resources",{"type":47,"tag":74,"props":2612,"children":2613},{},[2614,2629,2644,2659,2674],{"type":47,"tag":78,"props":2615,"children":2616},{},[2617,2622,2623],{"type":47,"tag":128,"props":2618,"children":2619},{},[2620],{"type":52,"value":2621},"Building Secure Contracts",{"type":52,"value":134},{"type":47,"tag":136,"props":2624,"children":2626},{"className":2625},[],[2627],{"type":52,"value":2628},"building-secure-contracts\u002Fnot-so-smart-contracts\u002Fsolana\u002F",{"type":47,"tag":78,"props":2630,"children":2631},{},[2632,2636,2637],{"type":47,"tag":128,"props":2633,"children":2634},{},[2635],{"type":52,"value":546},{"type":52,"value":134},{"type":47,"tag":667,"props":2638,"children":2642},{"href":2639,"rel":2640},"https:\u002F\u002Fgithub.com\u002Ftrailofbits\u002Fsolana-lints",[2641],"nofollow",[2643],{"type":52,"value":2639},{"type":47,"tag":78,"props":2645,"children":2646},{},[2647,2652,2653],{"type":47,"tag":128,"props":2648,"children":2649},{},[2650],{"type":52,"value":2651},"Anchor Documentation",{"type":52,"value":134},{"type":47,"tag":667,"props":2654,"children":2657},{"href":2655,"rel":2656},"https:\u002F\u002Fwww.anchor-lang.com\u002F",[2641],[2658],{"type":52,"value":2655},{"type":47,"tag":78,"props":2660,"children":2661},{},[2662,2667,2668],{"type":47,"tag":128,"props":2663,"children":2664},{},[2665],{"type":52,"value":2666},"Solana Program Library",{"type":52,"value":134},{"type":47,"tag":667,"props":2669,"children":2672},{"href":2670,"rel":2671},"https:\u002F\u002Fgithub.com\u002Fsolana-labs\u002Fsolana-program-library",[2641],[2673],{"type":52,"value":2670},{"type":47,"tag":78,"props":2675,"children":2676},{},[2677,2682,2683],{"type":47,"tag":128,"props":2678,"children":2679},{},[2680],{"type":52,"value":2681},"Solana Cookbook",{"type":52,"value":134},{"type":47,"tag":667,"props":2684,"children":2687},{"href":2685,"rel":2686},"https:\u002F\u002Fsolanacookbook.com\u002F",[2641],[2688],{"type":52,"value":2685},{"type":47,"tag":575,"props":2690,"children":2691},{},[],{"type":47,"tag":55,"props":2693,"children":2695},{"id":2694},"_12-quick-reference-checklist",[2696],{"type":52,"value":2697},"12. Quick Reference Checklist",{"type":47,"tag":62,"props":2699,"children":2700},{},[2701],{"type":52,"value":2702},"Before completing Solana program audit:",{"type":47,"tag":62,"props":2704,"children":2705},{},[2706,2711],{"type":47,"tag":128,"props":2707,"children":2708},{},[2709],{"type":52,"value":2710},"CPI Security (CRITICAL)",{"type":52,"value":1745},{"type":47,"tag":74,"props":2713,"children":2715},{"className":2714},[882],[2716,2731,2740],{"type":47,"tag":78,"props":2717,"children":2719},{"className":2718},[887],[2720,2723,2725],{"type":47,"tag":890,"props":2721,"children":2722},{"disabled":248,"type":892},[],{"type":52,"value":2724}," ALL CPI calls validate program ID before ",{"type":47,"tag":136,"props":2726,"children":2728},{"className":2727},[],[2729],{"type":52,"value":2730},"invoke()",{"type":47,"tag":78,"props":2732,"children":2734},{"className":2733},[887],[2735,2738],{"type":47,"tag":890,"props":2736,"children":2737},{"disabled":248,"type":892},[],{"type":52,"value":2739}," Cannot use user-provided program accounts",{"type":47,"tag":78,"props":2741,"children":2743},{"className":2742},[887],[2744,2747,2748,2753],{"type":47,"tag":890,"props":2745,"children":2746},{"disabled":248,"type":892},[],{"type":52,"value":913},{"type":47,"tag":136,"props":2749,"children":2751},{"className":2750},[],[2752],{"type":52,"value":919},{"type":52,"value":921},{"type":47,"tag":62,"props":2755,"children":2756},{},[2757,2762],{"type":47,"tag":128,"props":2758,"children":2759},{},[2760],{"type":52,"value":2761},"PDA Security (CRITICAL)",{"type":52,"value":1745},{"type":47,"tag":74,"props":2764,"children":2766},{"className":2765},[882],[2767,2788,2797],{"type":47,"tag":78,"props":2768,"children":2770},{"className":2769},[887],[2771,2774,2776,2781,2782,2787],{"type":47,"tag":890,"props":2772,"children":2773},{"disabled":248,"type":892},[],{"type":52,"value":2775}," PDAs use ",{"type":47,"tag":136,"props":2777,"children":2779},{"className":2778},[],[2780],{"type":52,"value":1053},{"type":52,"value":1055},{"type":47,"tag":136,"props":2783,"children":2785},{"className":2784},[],[2786],{"type":52,"value":1061},{"type":52,"value":1063},{"type":47,"tag":78,"props":2789,"children":2791},{"className":2790},[887],[2792,2795],{"type":47,"tag":890,"props":2793,"children":2794},{"disabled":248,"type":892},[],{"type":52,"value":2796}," Bump seed stored and reused (not user-provided)",{"type":47,"tag":78,"props":2798,"children":2800},{"className":2799},[887],[2801,2804],{"type":47,"tag":890,"props":2802,"children":2803},{"disabled":248,"type":892},[],{"type":52,"value":2805}," PDA accounts validated against canonical address",{"type":47,"tag":62,"props":2807,"children":2808},{},[2809,2814],{"type":47,"tag":128,"props":2810,"children":2811},{},[2812],{"type":52,"value":2813},"Account Validation (HIGH)",{"type":52,"value":1745},{"type":47,"tag":74,"props":2816,"children":2818},{"className":2817},[882],[2819,2828,2843],{"type":47,"tag":78,"props":2820,"children":2822},{"className":2821},[887],[2823,2826],{"type":47,"tag":890,"props":2824,"children":2825},{"disabled":248,"type":892},[],{"type":52,"value":2827}," ALL accounts check owner before deserialization",{"type":47,"tag":78,"props":2829,"children":2831},{"className":2830},[887],[2832,2835,2837],{"type":47,"tag":890,"props":2833,"children":2834},{"disabled":248,"type":892},[],{"type":52,"value":2836}," Native: Validates ",{"type":47,"tag":136,"props":2838,"children":2840},{"className":2839},[],[2841],{"type":52,"value":2842},"account.owner == expected_program_id",{"type":47,"tag":78,"props":2844,"children":2846},{"className":2845},[887],[2847,2850,2851,2856],{"type":47,"tag":890,"props":2848,"children":2849},{"disabled":248,"type":892},[],{"type":52,"value":913},{"type":47,"tag":136,"props":2852,"children":2854},{"className":2853},[],[2855],{"type":52,"value":1206},{"type":52,"value":921},{"type":47,"tag":62,"props":2858,"children":2859},{},[2860,2865],{"type":47,"tag":128,"props":2861,"children":2862},{},[2863],{"type":52,"value":2864},"Signer Validation (CRITICAL)",{"type":52,"value":1745},{"type":47,"tag":74,"props":2867,"children":2869},{"className":2868},[882],[2870,2885,2899],{"type":47,"tag":78,"props":2871,"children":2873},{"className":2872},[887],[2874,2877,2879],{"type":47,"tag":890,"props":2875,"children":2876},{"disabled":248,"type":892},[],{"type":52,"value":2878}," ALL authority accounts check ",{"type":47,"tag":136,"props":2880,"children":2882},{"className":2881},[],[2883],{"type":52,"value":2884},"is_signer",{"type":47,"tag":78,"props":2886,"children":2888},{"className":2887},[887],[2889,2892,2893],{"type":47,"tag":890,"props":2890,"children":2891},{"disabled":248,"type":892},[],{"type":52,"value":2836},{"type":47,"tag":136,"props":2894,"children":2896},{"className":2895},[],[2897],{"type":52,"value":2898},"account.is_signer == true",{"type":47,"tag":78,"props":2900,"children":2902},{"className":2901},[887],[2903,2906,2907,2912],{"type":47,"tag":890,"props":2904,"children":2905},{"disabled":248,"type":892},[],{"type":52,"value":913},{"type":47,"tag":136,"props":2908,"children":2910},{"className":2909},[],[2911],{"type":52,"value":1214},{"type":52,"value":921},{"type":47,"tag":62,"props":2914,"children":2915},{},[2916,2921],{"type":47,"tag":128,"props":2917,"children":2918},{},[2919],{"type":52,"value":2920},"Sysvar Security (HIGH)",{"type":52,"value":1745},{"type":47,"tag":74,"props":2923,"children":2925},{"className":2924},[882],[2926,2935,2950],{"type":47,"tag":78,"props":2927,"children":2929},{"className":2928},[887],[2930,2933],{"type":47,"tag":890,"props":2931,"children":2932},{"disabled":248,"type":892},[],{"type":52,"value":2934}," Using Solana 1.8.1+",{"type":47,"tag":78,"props":2936,"children":2938},{"className":2937},[887],[2939,2942,2944],{"type":47,"tag":890,"props":2940,"children":2941},{"disabled":248,"type":892},[],{"type":52,"value":2943}," Using checked functions: ",{"type":47,"tag":136,"props":2945,"children":2947},{"className":2946},[],[2948],{"type":52,"value":2949},"load_instruction_at_checked()",{"type":47,"tag":78,"props":2951,"children":2953},{"className":2952},[887],[2954,2957],{"type":47,"tag":890,"props":2955,"children":2956},{"disabled":248,"type":892},[],{"type":52,"value":2958}," Sysvar addresses validated",{"type":47,"tag":62,"props":2960,"children":2961},{},[2962,2967],{"type":47,"tag":128,"props":2963,"children":2964},{},[2965],{"type":52,"value":2966},"Instruction Introspection (MEDIUM)",{"type":52,"value":1745},{"type":47,"tag":74,"props":2969,"children":2971},{"className":2970},[882],[2972,2981,2990],{"type":47,"tag":78,"props":2973,"children":2975},{"className":2974},[887],[2976,2979],{"type":47,"tag":890,"props":2977,"children":2978},{"disabled":248,"type":892},[],{"type":52,"value":2980}," Using relative indexes for correlation",{"type":47,"tag":78,"props":2982,"children":2984},{"className":2983},[887],[2985,2988],{"type":47,"tag":890,"props":2986,"children":2987},{"disabled":248,"type":892},[],{"type":52,"value":2989}," Proper validation between related instructions",{"type":47,"tag":78,"props":2991,"children":2993},{"className":2992},[887],[2994,2997],{"type":47,"tag":890,"props":2995,"children":2996},{"disabled":248,"type":892},[],{"type":52,"value":2998}," Cannot reuse same instruction across multiple calls",{"type":47,"tag":62,"props":3000,"children":3001},{},[3002,3007],{"type":47,"tag":128,"props":3003,"children":3004},{},[3005],{"type":52,"value":3006},"Testing",{"type":52,"value":1745},{"type":47,"tag":74,"props":3009,"children":3011},{"className":3010},[882],[3012,3021,3030,3039],{"type":47,"tag":78,"props":3013,"children":3015},{"className":3014},[887],[3016,3019],{"type":47,"tag":890,"props":3017,"children":3018},{"disabled":248,"type":892},[],{"type":52,"value":3020}," Unit tests cover all account validation",{"type":47,"tag":78,"props":3022,"children":3024},{"className":3023},[887],[3025,3028],{"type":47,"tag":890,"props":3026,"children":3027},{"disabled":248,"type":892},[],{"type":52,"value":3029}," Integration tests with malicious inputs",{"type":47,"tag":78,"props":3031,"children":3033},{"className":3032},[887],[3034,3037],{"type":47,"tag":890,"props":3035,"children":3036},{"disabled":248,"type":892},[],{"type":52,"value":3038}," Local validator testing completed",{"type":47,"tag":78,"props":3040,"children":3042},{"className":3041},[887],[3043,3046],{"type":47,"tag":890,"props":3044,"children":3045},{"disabled":248,"type":892},[],{"type":52,"value":3047}," Trail of Bits lints enabled and passing",{"type":47,"tag":3049,"props":3050,"children":3051},"style",{},[3052],{"type":52,"value":3053},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"items":3055,"total":3204},[3056,3072,3082,3100,3111,3124,3136,3146,3159,3170,3182,3193],{"slug":3057,"name":3057,"fn":3058,"description":3059,"org":3060,"tags":3061,"stars":29,"repoUrl":30,"updatedAt":3071},"address-sanitizer","detect memory errors during fuzzing","AddressSanitizer detects memory errors during fuzzing. Use when fuzzing C\u002FC++ code to find buffer overflows and use-after-free bugs.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3062,3065,3068,3069],{"name":3063,"slug":3064,"type":16},"C#","c",{"name":3066,"slug":3067,"type":16},"Debugging","debugging",{"name":14,"slug":15,"type":16},{"name":3006,"slug":3070,"type":16},"testing","2026-07-17T06:05:14.925095",{"slug":3073,"name":3073,"fn":3074,"description":3075,"org":3076,"tags":3077,"stars":29,"repoUrl":30,"updatedAt":3081},"aflpp","perform multi-core fuzzing of C\u002FC++ projects","AFL++ is a fork of AFL with better fuzzing performance and advanced features. Use for multi-core fuzzing of C\u002FC++ projects.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3078,3079,3080],{"name":3063,"slug":3064,"type":16},{"name":14,"slug":15,"type":16},{"name":3006,"slug":3070,"type":16},"2026-07-17T06:05:12.433192",{"slug":3083,"name":3083,"fn":3084,"description":3085,"org":3086,"tags":3087,"stars":29,"repoUrl":30,"updatedAt":3099},"agentic-actions-auditor","audit GitHub Actions for security vulnerabilities","Audits GitHub Actions workflows for security vulnerabilities in AI agent integrations including Claude Code Action, Gemini CLI, OpenAI Codex, and GitHub AI Inference. Detects attack vectors where attacker-controlled input reaches AI agents running in CI\u002FCD pipelines, including env var intermediary patterns, direct expression injection, dangerous sandbox configurations, and wildcard user allowlists. Use when reviewing workflow files that invoke AI coding agents, auditing CI\u002FCD pipeline security for prompt injection risks, or evaluating agentic action configurations.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3088,3091,3094,3095,3098],{"name":3089,"slug":3090,"type":16},"Agents","agents",{"name":3092,"slug":3093,"type":16},"CI\u002FCD","ci-cd",{"name":27,"slug":28,"type":16},{"name":3096,"slug":3097,"type":16},"GitHub Actions","github-actions",{"name":14,"slug":15,"type":16},"2026-07-18T05:47:48.564744",{"slug":3101,"name":3101,"fn":3102,"description":3103,"org":3104,"tags":3105,"stars":29,"repoUrl":30,"updatedAt":3110},"algorand-vulnerability-scanner","scan Algorand smart contracts for vulnerabilities","Scans Algorand smart contracts for 11 common vulnerabilities including rekeying attacks, unchecked transaction fees, missing field validations, and access control issues. Use when auditing Algorand projects (TEAL\u002FPyTeal).",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3106,3107,3108,3109],{"name":18,"slug":19,"type":16},{"name":27,"slug":28,"type":16},{"name":14,"slug":15,"type":16},{"name":21,"slug":22,"type":16},"2026-07-18T05:47:43.989063",{"slug":3112,"name":3112,"fn":3113,"description":3114,"org":3115,"tags":3116,"stars":29,"repoUrl":30,"updatedAt":3123},"ask-questions-if-underspecified","clarify requirements before implementation","Clarify requirements before implementing. Use when serious doubts arise.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3117,3120],{"name":3118,"slug":3119,"type":16},"Engineering","engineering",{"name":3121,"slug":3122,"type":16},"Productivity","productivity","2026-07-17T06:05:33.543262",{"slug":3125,"name":3125,"fn":3126,"description":3127,"org":3128,"tags":3129,"stars":29,"repoUrl":30,"updatedAt":3135},"atheris","fuzz Python code with Atheris","Atheris is a coverage-guided Python fuzzer based on libFuzzer. Use for fuzzing pure Python code and Python C extensions.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3130,3133,3134],{"name":3131,"slug":3132,"type":16},"Python","python",{"name":14,"slug":15,"type":16},{"name":3006,"slug":3070,"type":16},"2026-07-17T06:05:14.575191",{"slug":3137,"name":3137,"fn":3138,"description":3139,"org":3140,"tags":3141,"stars":29,"repoUrl":30,"updatedAt":3145},"audit-augmentation","augment code graphs with audit findings","Augments Trailmark code graphs with external audit findings from SARIF static analysis results, weAudit annotation files, and version-gated Trailmark 0.4.x binary-analysis graph exports. Maps findings to graph nodes by file and line overlap, creates severity-based subgraphs, and enables cross-referencing findings with pre-analysis data (blast radius, taint, etc.). Use when projecting SARIF results onto a code graph, overlaying weAudit annotations, importing binary graph findings, cross-referencing Semgrep, CodeQL, or binary-analysis findings with call graph data, or visualizing audit findings in the context of code structure.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3142,3143,3144],{"name":18,"slug":19,"type":16},{"name":27,"slug":28,"type":16},{"name":14,"slug":15,"type":16},"2026-08-01T05:44:54.920542",{"slug":3147,"name":3147,"fn":3148,"description":3149,"org":3150,"tags":3151,"stars":29,"repoUrl":30,"updatedAt":3158},"audit-context-building","build architectural context for code analysis","Enables ultra-granular, line-by-line code analysis to build deep architectural context before vulnerability or bug finding.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3152,3155,3156,3157],{"name":3153,"slug":3154,"type":16},"Architecture","architecture",{"name":18,"slug":19,"type":16},{"name":27,"slug":28,"type":16},{"name":3118,"slug":3119,"type":16},"2026-07-18T05:47:40.122449",{"slug":3160,"name":3160,"fn":3161,"description":3162,"org":3163,"tags":3164,"stars":29,"repoUrl":30,"updatedAt":3169},"audit-prep-assistant","prepare codebases for security audits","Prepares codebases for security review using Trail of Bits' checklist. Helps set review goals, runs static analysis tools, increases test coverage, removes dead code, ensures accessibility, and generates documentation (flowcharts, user stories, inline comments).",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3165,3166,3167,3168],{"name":18,"slug":19,"type":16},{"name":27,"slug":28,"type":16},{"name":3118,"slug":3119,"type":16},{"name":14,"slug":15,"type":16},"2026-07-18T05:47:39.210985",{"slug":3171,"name":3171,"fn":3172,"description":3173,"org":3174,"tags":3175,"stars":29,"repoUrl":30,"updatedAt":3181},"burpsuite-project-parser","parse Burp Suite project files","Searches and explores Burp Suite project files (.burp) from the command line. Use when searching response headers or bodies with regex patterns, extracting security audit findings, dumping proxy history or site map data, or analyzing HTTP traffic captured in a Burp project.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3176,3177,3180],{"name":18,"slug":19,"type":16},{"name":3178,"slug":3179,"type":16},"CLI","cli",{"name":14,"slug":15,"type":16},"2026-07-17T06:05:33.198077",{"slug":3183,"name":3183,"fn":3184,"description":3185,"org":3186,"tags":3187,"stars":29,"repoUrl":30,"updatedAt":3192},"c-review","audit C and C++ code","Performs comprehensive C\u002FC++ security review for memory corruption, integer overflows, race conditions, and platform-specific vulnerabilities. Use when auditing native C\u002FC++ applications, reviewing daemons or services for memory safety, or hunting integer overflow \u002F use-after-free \u002F race conditions in userspace code.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3188,3189,3190,3191],{"name":18,"slug":19,"type":16},{"name":3063,"slug":3064,"type":16},{"name":27,"slug":28,"type":16},{"name":14,"slug":15,"type":16},"2026-07-17T06:05:11.333374",{"slug":3194,"name":3194,"fn":3195,"description":3196,"org":3197,"tags":3198,"stars":29,"repoUrl":30,"updatedAt":3203},"cairo-vulnerability-scanner","scan Cairo and StarkNet contracts for vulnerabilities","Scans Cairo\u002FStarkNet smart contracts for 6 critical vulnerabilities including felt252 arithmetic overflow, L1-L2 messaging issues, address conversion problems, and signature replay. Use when auditing StarkNet projects.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3199,3200,3201,3202],{"name":18,"slug":19,"type":16},{"name":27,"slug":28,"type":16},{"name":14,"slug":15,"type":16},{"name":21,"slug":22,"type":16},"2026-07-18T05:47:42.84568",111,{"items":3206,"total":3252},[3207,3214,3220,3228,3235,3240,3246],{"slug":3057,"name":3057,"fn":3058,"description":3059,"org":3208,"tags":3209,"stars":29,"repoUrl":30,"updatedAt":3071},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3210,3211,3212,3213],{"name":3063,"slug":3064,"type":16},{"name":3066,"slug":3067,"type":16},{"name":14,"slug":15,"type":16},{"name":3006,"slug":3070,"type":16},{"slug":3073,"name":3073,"fn":3074,"description":3075,"org":3215,"tags":3216,"stars":29,"repoUrl":30,"updatedAt":3081},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3217,3218,3219],{"name":3063,"slug":3064,"type":16},{"name":14,"slug":15,"type":16},{"name":3006,"slug":3070,"type":16},{"slug":3083,"name":3083,"fn":3084,"description":3085,"org":3221,"tags":3222,"stars":29,"repoUrl":30,"updatedAt":3099},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3223,3224,3225,3226,3227],{"name":3089,"slug":3090,"type":16},{"name":3092,"slug":3093,"type":16},{"name":27,"slug":28,"type":16},{"name":3096,"slug":3097,"type":16},{"name":14,"slug":15,"type":16},{"slug":3101,"name":3101,"fn":3102,"description":3103,"org":3229,"tags":3230,"stars":29,"repoUrl":30,"updatedAt":3110},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3231,3232,3233,3234],{"name":18,"slug":19,"type":16},{"name":27,"slug":28,"type":16},{"name":14,"slug":15,"type":16},{"name":21,"slug":22,"type":16},{"slug":3112,"name":3112,"fn":3113,"description":3114,"org":3236,"tags":3237,"stars":29,"repoUrl":30,"updatedAt":3123},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3238,3239],{"name":3118,"slug":3119,"type":16},{"name":3121,"slug":3122,"type":16},{"slug":3125,"name":3125,"fn":3126,"description":3127,"org":3241,"tags":3242,"stars":29,"repoUrl":30,"updatedAt":3135},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3243,3244,3245],{"name":3131,"slug":3132,"type":16},{"name":14,"slug":15,"type":16},{"name":3006,"slug":3070,"type":16},{"slug":3137,"name":3137,"fn":3138,"description":3139,"org":3247,"tags":3248,"stars":29,"repoUrl":30,"updatedAt":3145},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3249,3250,3251],{"name":18,"slug":19,"type":16},{"name":27,"slug":28,"type":16},{"name":14,"slug":15,"type":16},77]