[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79XJSZVVP3SBX8A96ET2TQH":3,"skill-same:01M79XJSZVVP3SBX8A96ET2TQH":60},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":23,"commitSha":24,"skillDirectory":25,"forksCount":13,"repositoryHtmlUrl":26,"repositoryHomepageUrl":27,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":29,"install":30,"resources":43},"01M79XJSZVVP3SBX8A96ET2TQH","cairo-vulnerability-scanner",null,"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.","Heesho\u002Fraffle-fun","Heesho","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F100749457?v=4","01M79XHBVXHD5BHPJTHXK51VSC","01M79XHBWZQNAH0BTYT9A1RFCW",0,"MIT","https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FDAYBREAK-TOB\u002Fattempt-02\u002Fruntime\u002Fcodex-home\u002Fplugins\u002Fcache\u002Ftrailofbits\u002Fbuilding-secure-contracts\u002F1.2.2\u002Fskills\u002Fcairo-vulnerability-scanner\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: cairo-vulnerability-scanner\ndescription: 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.\n---\n\n# Cairo\u002FStarkNet Vulnerability Scanner\n\n## 1. Purpose\n\nSystematically scan Cairo smart contracts on StarkNet for platform-specific security vulnerabilities related to arithmetic, cross-layer messaging, and cryptographic operations. This skill encodes 6 critical vulnerability patterns unique to Cairo\u002FStarkNet ecosystem.\n\n## 2. When to Use This Skill\n\n- Auditing StarkNet smart contracts (Cairo)\n- Reviewing L1-L2 bridge implementations\n- Pre-launch security assessment of StarkNet applications\n- Validating cross-layer message handling\n- Reviewing signature verification logic\n- Assessing L1 handler functions\n\n## 3. Platform Detection\n\n### File Extensions & Indicators\n- **Cairo files**: `.cairo`\n\n### Language\u002FFramework Markers\n```rust\n\u002F\u002F Cairo contract indicators\n#[contract]\nmod MyContract {\n    use starknet::ContractAddress;\n\n    #[storage]\n    struct Storage {\n        balance: LegacyMap\u003CContractAddress, felt252>,\n    }\n\n    #[external(v0)]\n    fn transfer(ref self: ContractState, to: ContractAddress, amount: felt252) {\n        \u002F\u002F Contract logic\n    }\n\n    #[l1_handler]\n    fn handle_deposit(ref self: ContractState, from_address: felt252, amount: u256) {\n        \u002F\u002F L1 message handler\n    }\n}\n\n\u002F\u002F Common patterns\nfelt252, u128, u256\nContractAddress, EthAddress\n#[external(v0)], #[l1_handler], #[constructor]\nget_caller_address(), get_contract_address()\nsend_message_to_l1_syscall\n```\n\n### Project Structure\n- `src\u002Fcontract.cairo` - Main contract implementation\n- `src\u002Flib.cairo` - Library modules\n- `tests\u002F` - Contract tests\n- `Scarb.toml` - Cairo project configuration\n\n### Tool Support\n- **Caracal**: Trail of Bits static analyzer for Cairo\n- Installation: `cargo install --git https:\u002F\u002Fgithub.com\u002Fcrytic\u002Fcaracal --profile release --force` (a Rust tool — not on PyPI)\n- Usage: `caracal detect src\u002F`\n- **cairo-test**: Built-in testing framework\n- **Starknet Foundry**: Testing and development toolkit\n\n---\n\n## 4. How This Skill Works\n\nWhen invoked, I will:\n\n1. **Search your codebase** for Cairo files\n2. **Analyze each contract** for the 6 vulnerability patterns\n3. **Report findings** with file references and severity, above them a coverage table carrying a verdict for every pattern\n4. **Provide fixes** for each identified issue\n5. **Check L1-L2 interactions** for messaging vulnerabilities\n\n---\n\n## 5. Example Output\n\nWhen vulnerabilities are found, you'll get a report like this:\n\n```\n=== CAIRO\u002FSTARKNET VULNERABILITY SCAN RESULTS ===\n```\n\n---\n\n## 6. Vulnerability Patterns (6 Patterns)\n\nI check for 6 critical vulnerability patterns unique to Cairo\u002FStarknet. For detailed detection patterns, code examples, mitigations, and testing strategies, see [VULNERABILITY_PATTERNS.md](resources\u002FVULNERABILITY_PATTERNS.md).\n\n### Pattern Summary:\n\n1. **Felt252 Arithmetic Overflow\u002FUnderflow** ⚠️ HIGH - `felt252` wraps silently; use `u128`\u002F`u256`\n2. **L1 to L2 Address Conversion** ⚠️ HIGH - L1 address not validated against STARKNET_FIELD_PRIME\n3. **L1 to L2 Message Failure** ⚠️ HIGH - No cancellation path when a message cannot be consumed\n4. **Overconstrained L1 \u003C-> L2 Interaction** ⚠️ MEDIUM - Coupling that can strand funds or block progress\n5. **Signature Replay Protection** ⚠️ HIGH - No nonce, or a domain separator missing chain\u002Fcontract\n6. **Unchecked from_address in L1 Handler** ⚠️ CRITICAL - Any L1 contract can drive the handler\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 Cairo language and StarkNet framework\n2. Check Cairo version (Cairo 1.0+ vs legacy Cairo 0)\n3. Locate contract files (`src\u002F*.cairo`)\n4. Identify L1-L2 bridge contracts (if applicable)\n\n### Step 2: Arithmetic Safety Sweep\n```bash\n# Find felt252 usage in arithmetic\nrg \"felt252\" src\u002F | rg \"[-+*\u002F]\"\n\n# Find balance\u002Famount storage using felt252\nrg \"felt252\" src\u002F | rg \"balance|amount|total|supply\"\n\n# Should prefer u128, u256 instead\n```\n\n### Step 3: L1 Handler Analysis\nFor each `#[l1_handler]` function:\n- [ ] Validates `from_address` parameter\n- [ ] Checks address != zero\n- [ ] Has proper access control\n- [ ] Emits events for monitoring\n\n### Step 4: Signature Verification Review\nFor signature-based functions:\n- [ ] Includes nonce tracking\n- [ ] Nonce incremented after use\n- [ ] Domain separator includes chain ID and contract address\n- [ ] Cannot replay signatures\n\n### Step 5: L1-L2 Bridge Audit\nIf contract includes bridge functionality:\n- [ ] L1 validates address \u003C STARKNET_FIELD_PRIME\n- [ ] L1 implements message cancellation\n- [ ] L2 validates from_address in handlers\n- [ ] Symmetric access controls L1 ↔ L2\n- [ ] Test full roundtrip flows\n\n### Step 6: Static Analysis with Caracal\n```bash\n# Run Caracal detectors\ncaracal detect src\u002F\n\n# Specific detectors\ncaracal detect src\u002F --detectors unchecked-felt252-arithmetic\ncaracal detect src\u002F --detectors unchecked-l1-handler-from\ncaracal detect src\u002F --detectors missing-nonce-validation\n```\n\n---\n\n## 8. Reporting Format\n\n### Coverage Table\n\nReport on every pattern in §6, whether or not it turned anything up. Emit this table above the findings, with\nall 6 rows present:\n\n| # | Pattern | Verdict | Evidence |\n|---|---------|---------|----------|\n| 1 | Felt252 Arithmetic Overflow\u002FUnderflow | `clear` | balances are `u256`; searched `felt252` in arithmetic, none |\n| 2 | L1 to L2 Address Conversion | | |\n| 3 | L1 to L2 Message Failure | | |\n| 4 | Overconstrained L1 \u003C-> L2 Interaction | | |\n| 5 | Signature Replay Protection | | |\n| 6 | Unchecked from_address in L1 Handler | | |\n\nEach verdict is one of:\n\n- **`found`** — cite `file:line` and write the finding up in full below.\n- **`clear`** — the pattern applies to this contract and the contract handles it. Name the function, trait, or\n  check you searched for, so a reader can repeat the search.\n- **`n\u002Fa`** — the pattern cannot apply here. Give the reason in one clause (\"no L1 handlers in this contract\").\n  Not having looked is not `n\u002Fa`.\n\nA table with fewer than 6 rows is an incomplete scan and must be reported as one. A row whose Verdict cell is empty is incomplete in the same way: row 1 above is filled in to show the shape, and every row is filled in the same way before the report is done. Six `clear` verdicts is a\nresult a reader can act on. A report that covers two patterns and says nothing about the other four reads\nexactly like a clean contract, and that is the failure this table exists to prevent.\n\n### Finding Template\n````markdown\n## [CRITICAL] Unchecked from_address in L1 Handler\n\n**Location**: `src\u002Fbridge.cairo:145-155` (handle_deposit function)\n\n**Description**:\nThe `handle_deposit` L1 handler function does not validate the `from_address` parameter. Any L1 contract can send messages to this function and mint tokens for arbitrary users, bypassing the intended L1 bridge access controls.\n\n**Vulnerable Code**:\n```rust\n\u002F\u002F bridge.cairo, line 145\n#[l1_handler]\nfn handle_deposit(\n    ref self: ContractState,\n    from_address: felt252,  \u002F\u002F Not validated!\n    user: ContractAddress,\n    amount: u256\n) {\n    let current_balance = self.balances.read(user);\n    self.balances.write(user, current_balance + amount);\n}\n```\n\n**Attack Scenario**:\n1. Attacker deploys malicious L1 contract\n2. Malicious contract calls `starknetCore.sendMessageToL2(l2Contract, selector, [attacker_address, 1000000])`\n3. L2 handler processes message without checking sender\n4. Attacker receives 1,000,000 tokens without depositing any funds\n5. Protocol suffers infinite mint vulnerability\n\n**Recommendation**:\nValidate `from_address` against authorized L1 bridge:\n```rust\n#[l1_handler]\nfn handle_deposit(\n    ref self: ContractState,\n    from_address: felt252,\n    user: ContractAddress,\n    amount: u256\n) {\n    \u002F\u002F Validate L1 sender\n    let authorized_l1_bridge = self.l1_bridge_address.read();\n    assert(from_address == authorized_l1_bridge, 'Unauthorized L1 sender');\n\n    let current_balance = self.balances.read(user);\n    self.balances.write(user, current_balance + amount);\n}\n```\n\n**References**:\n- building-secure-contracts\u002Fnot-so-smart-contracts\u002Fcairo\u002Funchecked_l1_handler_from\n- Caracal detector: `unchecked-l1-handler-from`\n````\n\n---\n\n## 9. Priority Guidelines\n\n### Critical (Immediate Fix Required)\n- Unchecked from_address in L1 handlers (infinite mint)\n- L1-L2 address conversion issues (funds to zero address)\n\n### High (Fix Before Deployment)\n- Felt252 arithmetic overflow\u002Funderflow (balance manipulation)\n- Missing signature replay protection (replay attacks)\n- L1-L2 message failure without cancellation (locked funds)\n\n### Medium (Address in Audit)\n- Overconstrained L1-L2 interactions (trapped funds)\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    fn test_felt252_overflow() {\n        \u002F\u002F Test arithmetic edge cases\n    }\n\n    #[test]\n    #[should_panic]\n    fn test_unauthorized_l1_handler() {\n        \u002F\u002F Wrong from_address should fail\n    }\n\n    #[test]\n    fn test_signature_replay_protection() {\n        \u002F\u002F Same signature twice should fail\n    }\n}\n```\n\n### Integration Tests (with L1)\n```rust\n\u002F\u002F Test full L1-L2 flow\n#[test]\nfn test_deposit_withdraw_roundtrip() {\n    \u002F\u002F 1. Deposit on L1\n    \u002F\u002F 2. Wait for L2 processing\n    \u002F\u002F 3. Verify L2 balance\n    \u002F\u002F 4. Withdraw to L1\n    \u002F\u002F 5. Verify L1 balance restored\n}\n```\n\n### Caracal CI Integration\n```yaml\n# .github\u002Fworkflows\u002Fsecurity.yml\n- name: Run Caracal\n  run: |\n    # Rebuilds from source each run; cache ~\u002F.cargo or pin a release binary instead.\n    cargo install --git https:\u002F\u002Fgithub.com\u002Fcrytic\u002Fcaracal --profile release --force\n    caracal detect src\u002F --fail-on high,critical\n```\n\n---\n\n## 11. Additional Resources\n\n- **Building Secure Contracts**: `building-secure-contracts\u002Fnot-so-smart-contracts\u002Fcairo\u002F`\n- **Caracal**: https:\u002F\u002Fgithub.com\u002Fcrytic\u002Fcaracal\n- **Cairo Documentation**: https:\u002F\u002Fbook.cairo-lang.org\u002F\n- **StarkNet Documentation**: https:\u002F\u002Fdocs.starknet.io\u002F\n- **OpenZeppelin Cairo Contracts**: https:\u002F\u002Fgithub.com\u002FOpenZeppelin\u002Fcairo-contracts\n\n---\n\n## 12. Quick Reference Checklist\n\nBefore completing Cairo\u002FStarkNet audit:\n\n**Arithmetic Safety (HIGH)**:\n- [ ] No felt252 used for balances\u002Famounts (use u128\u002Fu256)\n- [ ] OR felt252 arithmetic has explicit bounds checking\n- [ ] Overflow\u002Funderflow scenarios tested\n\n**L1 Handler Security (CRITICAL)**:\n- [ ] ALL `#[l1_handler]` functions validate `from_address`\n- [ ] from_address compared against stored L1 contract address\n- [ ] Cannot bypass by deploying alternate L1 contract\n\n**L1-L2 Messaging (HIGH)**:\n- [ ] L1 bridge validates addresses \u003C STARKNET_FIELD_PRIME\n- [ ] L1 bridge implements message cancellation\n- [ ] L2 handlers check from_address\n- [ ] Symmetric validation rules L1 ↔ L2\n- [ ] Full roundtrip flows tested\n\n**Signature Security (HIGH)**:\n- [ ] Signatures include nonce tracking\n- [ ] Nonce incremented after each use\n- [ ] Domain separator includes chain ID and contract address\n- [ ] Signature replay tested and prevented\n- [ ] Cross-chain replay prevented\n\n**Tool Usage**:\n- [ ] Caracal scan completed with no critical findings\n- [ ] Unit tests cover all vulnerability scenarios\n- [ ] Integration tests verify L1-L2 flows\n- [ ] Testnet deployment tested before mainnet\n- [ ] Coverage table emitted with all 6 rows, each carrying a verdict of `found`, `clear` or `n\u002Fa` with a reason\n\n---\n\n## 13. Rationalizations to Reject\n\n- **\"The contract is small, so most patterns obviously don't apply.\"** Obvious to whom? An `n\u002Fa` costs one\n  clause and makes the judgment reviewable. Silence records nothing, and a reader cannot tell it apart from\n  not having checked.\n- **\"Caracal reported nothing, so the contract is clean.\"** Caracal covers a subset of these 6 patterns and\n  does not reach the logic-level ones at all. A clean tool run is one row of evidence, not a verdict on the\n  patterns it never examined. Say which patterns it covered.\n- **\"I checked the patterns that matter for this contract.\"** Deciding which patterns matter *is* the scan,\n  not a precondition for starting it. Rank by severity after the table is complete, not by leaving rows out.\n- **\"No findings, so there is nothing to report.\"** A zero-finding scan still emits the full coverage table.\n  That table is the deliverable: it is what distinguishes a contract that was examined from one that was\n  glanced at.\n- **\"Cairo 1 has native overflow checks, so arithmetic is safe.\"** Name the types. `felt252` does not behave\n  like the sized integer types, and the boundary between them is where pattern 4 lives.\n- **\"The L1 side validates that.\"** Then cite the L1 contract. A check you believe exists across the bridge is\n  an assumption until you have read it, and unverified `from_address` is the canonical StarkNet bridge bug.\n","# Cairo\u002FStarkNet Vulnerability Scanner\n\n## 1. Purpose\n\nSystematically scan Cairo smart contracts on StarkNet for platform-specific security vulnerabilities related to arithmetic, cross-layer messaging, and cryptographic operations. This skill encodes 6 critical vulnerability patterns unique to Cairo\u002FStarkNet ecosystem.\n\n## 2. When to Use This Skill\n\n- Auditing StarkNet smart contracts (Cairo)\n- Reviewing L1-L2 bridge implementations\n- Pre-launch security assessment of StarkNet applications\n- Validating cross-layer message handling\n- Reviewing signature verification logic\n- Assessing L1 handler functions\n\n## 3. Platform Detection\n\n### File Extensions & Indicators\n- **Cairo files**: `.cairo`\n\n### Language\u002FFramework Markers\n```rust\n\u002F\u002F Cairo contract indicators\n#[contract]\nmod MyContract {\n    use starknet::ContractAddress;\n\n    #[storage]\n    struct Storage {\n        balance: LegacyMap\u003CContractAddress, felt252>,\n    }\n\n    #[external(v0)]\n    fn transfer(ref self: ContractState, to: ContractAddress, amount: felt252) {\n        \u002F\u002F Contract logic\n    }\n\n    #[l1_handler]\n    fn handle_deposit(ref self: ContractState, from_address: felt252, amount: u256) {\n        \u002F\u002F L1 message handler\n    }\n}\n\n\u002F\u002F Common patterns\nfelt252, u128, u256\nContractAddress, EthAddress\n#[external(v0)], #[l1_handler], #[constructor]\nget_caller_address(), get_contract_address()\nsend_message_to_l1_syscall\n```\n\n### Project Structure\n- `src\u002Fcontract.cairo` - Main contract implementation\n- `src\u002Flib.cairo` - Library modules\n- `tests\u002F` - Contract tests\n- `Scarb.toml` - Cairo project configuration\n\n### Tool Support\n- **Caracal**: Trail of Bits static analyzer for Cairo\n- Installation: `cargo install --git https:\u002F\u002Fgithub.com\u002Fcrytic\u002Fcaracal --profile release --force` (a Rust tool — not on PyPI)\n- Usage: `caracal detect src\u002F`\n- **cairo-test**: Built-in testing framework\n- **Starknet Foundry**: Testing and development toolkit\n\n---\n\n## 4. How This Skill Works\n\nWhen invoked, I will:\n\n1. **Search your codebase** for Cairo files\n2. **Analyze each contract** for the 6 vulnerability patterns\n3. **Report findings** with file references and severity, above them a coverage table carrying a verdict for every pattern\n4. **Provide fixes** for each identified issue\n5. **Check L1-L2 interactions** for messaging vulnerabilities\n\n---\n\n## 5. Example Output\n\nWhen vulnerabilities are found, you'll get a report like this:\n\n```\n=== CAIRO\u002FSTARKNET VULNERABILITY SCAN RESULTS ===\n```\n\n---\n\n## 6. Vulnerability Patterns (6 Patterns)\n\nI check for 6 critical vulnerability patterns unique to Cairo\u002FStarknet. For detailed detection patterns, code examples, mitigations, and testing strategies, see [VULNERABILITY_PATTERNS.md](resources\u002FVULNERABILITY_PATTERNS.md).\n\n### Pattern Summary:\n\n1. **Felt252 Arithmetic Overflow\u002FUnderflow** ⚠️ HIGH - `felt252` wraps silently; use `u128`\u002F`u256`\n2. **L1 to L2 Address Conversion** ⚠️ HIGH - L1 address not validated against STARKNET_FIELD_PRIME\n3. **L1 to L2 Message Failure** ⚠️ HIGH - No cancellation path when a message cannot be consumed\n4. **Overconstrained L1 \u003C-> L2 Interaction** ⚠️ MEDIUM - Coupling that can strand funds or block progress\n5. **Signature Replay Protection** ⚠️ HIGH - No nonce, or a domain separator missing chain\u002Fcontract\n6. **Unchecked from_address in L1 Handler** ⚠️ CRITICAL - Any L1 contract can drive the handler\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 Cairo language and StarkNet framework\n2. Check Cairo version (Cairo 1.0+ vs legacy Cairo 0)\n3. Locate contract files (`src\u002F*.cairo`)\n4. Identify L1-L2 bridge contracts (if applicable)\n\n### Step 2: Arithmetic Safety Sweep\n```bash\n# Find felt252 usage in arithmetic\nrg \"felt252\" src\u002F | rg \"[-+*\u002F]\"\n\n# Find balance\u002Famount storage using felt252\nrg \"felt252\" src\u002F | rg \"balance|amount|total|supply\"\n\n# Should prefer u128, u256 instead\n```\n\n### Step 3: L1 Handler Analysis\nFor each `#[l1_handler]` function:\n- [ ] Validates `from_address` parameter\n- [ ] Checks address != zero\n- [ ] Has proper access control\n- [ ] Emits events for monitoring\n\n### Step 4: Signature Verification Review\nFor signature-based functions:\n- [ ] Includes nonce tracking\n- [ ] Nonce incremented after use\n- [ ] Domain separator includes chain ID and contract address\n- [ ] Cannot replay signatures\n\n### Step 5: L1-L2 Bridge Audit\nIf contract includes bridge functionality:\n- [ ] L1 validates address \u003C STARKNET_FIELD_PRIME\n- [ ] L1 implements message cancellation\n- [ ] L2 validates from_address in handlers\n- [ ] Symmetric access controls L1 ↔ L2\n- [ ] Test full roundtrip flows\n\n### Step 6: Static Analysis with Caracal\n```bash\n# Run Caracal detectors\ncaracal detect src\u002F\n\n# Specific detectors\ncaracal detect src\u002F --detectors unchecked-felt252-arithmetic\ncaracal detect src\u002F --detectors unchecked-l1-handler-from\ncaracal detect src\u002F --detectors missing-nonce-validation\n```\n\n---\n\n## 8. Reporting Format\n\n### Coverage Table\n\nReport on every pattern in §6, whether or not it turned anything up. Emit this table above the findings, with\nall 6 rows present:\n\n| # | Pattern | Verdict | Evidence |\n|---|---------|---------|----------|\n| 1 | Felt252 Arithmetic Overflow\u002FUnderflow | `clear` | balances are `u256`; searched `felt252` in arithmetic, none |\n| 2 | L1 to L2 Address Conversion | | |\n| 3 | L1 to L2 Message Failure | | |\n| 4 | Overconstrained L1 \u003C-> L2 Interaction | | |\n| 5 | Signature Replay Protection | | |\n| 6 | Unchecked from_address in L1 Handler | | |\n\nEach verdict is one of:\n\n- **`found`** — cite `file:line` and write the finding up in full below.\n- **`clear`** — the pattern applies to this contract and the contract handles it. Name the function, trait, or\n  check you searched for, so a reader can repeat the search.\n- **`n\u002Fa`** — the pattern cannot apply here. Give the reason in one clause (\"no L1 handlers in this contract\").\n  Not having looked is not `n\u002Fa`.\n\nA table with fewer than 6 rows is an incomplete scan and must be reported as one. A row whose Verdict cell is empty is incomplete in the same way: row 1 above is filled in to show the shape, and every row is filled in the same way before the report is done. Six `clear` verdicts is a\nresult a reader can act on. A report that covers two patterns and says nothing about the other four reads\nexactly like a clean contract, and that is the failure this table exists to prevent.\n\n### Finding Template\n````markdown\n## [CRITICAL] Unchecked from_address in L1 Handler\n\n**Location**: `src\u002Fbridge.cairo:145-155` (handle_deposit function)\n\n**Description**:\nThe `handle_deposit` L1 handler function does not validate the `from_address` parameter. Any L1 contract can send messages to this function and mint tokens for arbitrary users, bypassing the intended L1 bridge access controls.\n\n**Vulnerable Code**:\n```rust\n\u002F\u002F bridge.cairo, line 145\n#[l1_handler]\nfn handle_deposit(\n    ref self: ContractState,\n    from_address: felt252,  \u002F\u002F Not validated!\n    user: ContractAddress,\n    amount: u256\n) {\n    let current_balance = self.balances.read(user);\n    self.balances.write(user, current_balance + amount);\n}\n```\n\n**Attack Scenario**:\n1. Attacker deploys malicious L1 contract\n2. Malicious contract calls `starknetCore.sendMessageToL2(l2Contract, selector, [attacker_address, 1000000])`\n3. L2 handler processes message without checking sender\n4. Attacker receives 1,000,000 tokens without depositing any funds\n5. Protocol suffers infinite mint vulnerability\n\n**Recommendation**:\nValidate `from_address` against authorized L1 bridge:\n```rust\n#[l1_handler]\nfn handle_deposit(\n    ref self: ContractState,\n    from_address: felt252,\n    user: ContractAddress,\n    amount: u256\n) {\n    \u002F\u002F Validate L1 sender\n    let authorized_l1_bridge = self.l1_bridge_address.read();\n    assert(from_address == authorized_l1_bridge, 'Unauthorized L1 sender');\n\n    let current_balance = self.balances.read(user);\n    self.balances.write(user, current_balance + amount);\n}\n```\n\n**References**:\n- building-secure-contracts\u002Fnot-so-smart-contracts\u002Fcairo\u002Funchecked_l1_handler_from\n- Caracal detector: `unchecked-l1-handler-from`\n````\n\n---\n\n## 9. Priority Guidelines\n\n### Critical (Immediate Fix Required)\n- Unchecked from_address in L1 handlers (infinite mint)\n- L1-L2 address conversion issues (funds to zero address)\n\n### High (Fix Before Deployment)\n- Felt252 arithmetic overflow\u002Funderflow (balance manipulation)\n- Missing signature replay protection (replay attacks)\n- L1-L2 message failure without cancellation (locked funds)\n\n### Medium (Address in Audit)\n- Overconstrained L1-L2 interactions (trapped funds)\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    fn test_felt252_overflow() {\n        \u002F\u002F Test arithmetic edge cases\n    }\n\n    #[test]\n    #[should_panic]\n    fn test_unauthorized_l1_handler() {\n        \u002F\u002F Wrong from_address should fail\n    }\n\n    #[test]\n    fn test_signature_replay_protection() {\n        \u002F\u002F Same signature twice should fail\n    }\n}\n```\n\n### Integration Tests (with L1)\n```rust\n\u002F\u002F Test full L1-L2 flow\n#[test]\nfn test_deposit_withdraw_roundtrip() {\n    \u002F\u002F 1. Deposit on L1\n    \u002F\u002F 2. Wait for L2 processing\n    \u002F\u002F 3. Verify L2 balance\n    \u002F\u002F 4. Withdraw to L1\n    \u002F\u002F 5. Verify L1 balance restored\n}\n```\n\n### Caracal CI Integration\n```yaml\n# .github\u002Fworkflows\u002Fsecurity.yml\n- name: Run Caracal\n  run: |\n    # Rebuilds from source each run; cache ~\u002F.cargo or pin a release binary instead.\n    cargo install --git https:\u002F\u002Fgithub.com\u002Fcrytic\u002Fcaracal --profile release --force\n    caracal detect src\u002F --fail-on high,critical\n```\n\n---\n\n## 11. Additional Resources\n\n- **Building Secure Contracts**: `building-secure-contracts\u002Fnot-so-smart-contracts\u002Fcairo\u002F`\n- **Caracal**: https:\u002F\u002Fgithub.com\u002Fcrytic\u002Fcaracal\n- **Cairo Documentation**: https:\u002F\u002Fbook.cairo-lang.org\u002F\n- **StarkNet Documentation**: https:\u002F\u002Fdocs.starknet.io\u002F\n- **OpenZeppelin Cairo Contracts**: https:\u002F\u002Fgithub.com\u002FOpenZeppelin\u002Fcairo-contracts\n\n---\n\n## 12. Quick Reference Checklist\n\nBefore completing Cairo\u002FStarkNet audit:\n\n**Arithmetic Safety (HIGH)**:\n- [ ] No felt252 used for balances\u002Famounts (use u128\u002Fu256)\n- [ ] OR felt252 arithmetic has explicit bounds checking\n- [ ] Overflow\u002Funderflow scenarios tested\n\n**L1 Handler Security (CRITICAL)**:\n- [ ] ALL `#[l1_handler]` functions validate `from_address`\n- [ ] from_address compared against stored L1 contract address\n- [ ] Cannot bypass by deploying alternate L1 contract\n\n**L1-L2 Messaging (HIGH)**:\n- [ ] L1 bridge validates addresses \u003C STARKNET_FIELD_PRIME\n- [ ] L1 bridge implements message cancellation\n- [ ] L2 handlers check from_address\n- [ ] Symmetric validation rules L1 ↔ L2\n- [ ] Full roundtrip flows tested\n\n**Signature Security (HIGH)**:\n- [ ] Signatures include nonce tracking\n- [ ] Nonce incremented after each use\n- [ ] Domain separator includes chain ID and contract address\n- [ ] Signature replay tested and prevented\n- [ ] Cross-chain replay prevented\n\n**Tool Usage**:\n- [ ] Caracal scan completed with no critical findings\n- [ ] Unit tests cover all vulnerability scenarios\n- [ ] Integration tests verify L1-L2 flows\n- [ ] Testnet deployment tested before mainnet\n- [ ] Coverage table emitted with all 6 rows, each carrying a verdict of `found`, `clear` or `n\u002Fa` with a reason\n\n---\n\n## 13. Rationalizations to Reject\n\n- **\"The contract is small, so most patterns obviously don't apply.\"** Obvious to whom? An `n\u002Fa` costs one\n  clause and makes the judgment reviewable. Silence records nothing, and a reader cannot tell it apart from\n  not having checked.\n- **\"Caracal reported nothing, so the contract is clean.\"** Caracal covers a subset of these 6 patterns and\n  does not reach the logic-level ones at all. A clean tool run is one row of evidence, not a verdict on the\n  patterns it never examined. Say which patterns it covered.\n- **\"I checked the patterns that matter for this contract.\"** Deciding which patterns matter *is* the scan,\n  not a precondition for starting it. Rank by severity after the table is complete, not by leaving rows out.\n- **\"No findings, so there is nothing to report.\"** A zero-finding scan still emits the full coverage table.\n  That table is the deliverable: it is what distinguishes a contract that was examined from one that was\n  glanced at.\n- **\"Cairo 1 has native overflow checks, so arithmetic is safe.\"** Name the types. `felt252` does not behave\n  like the sized integer types, and the boundary between them is where pattern 4 lives.\n- **\"The L1 side validates that.\"** Then cite the L1 contract. A check you believe exists across the bridge is\n  an assumption until you have read it, and unverified `from_address` is the canonical StarkNet bridge bug.\n",{"name":5,"description":7},"main","aa4fc8e4a5441efccc61aca4e77753a2e9f88c8b","audits\u002F2026-10-21-r001\u002Fruns\u002FDAYBREAK-TOB\u002Fattempt-02\u002Fruntime\u002Fcodex-home\u002Fplugins\u002Fcache\u002Ftrailofbits\u002Fbuilding-secure-contracts\u002F1.2.2\u002Fskills\u002Fcairo-vulnerability-scanner","https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun","https:\u002F\u002Fraffle-fun-lake.vercel.app","https:\u002F\u002Fgithub.com\u002FHeesho","2026-10-22 13:02:00",{"source":8,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add Heesho\u002Fraffle-fun --skill cairo-vulnerability-scanner",{"tool":36,"command":37},"bunx","bunx skills add Heesho\u002Fraffle-fun --skill cairo-vulnerability-scanner",{"tool":39,"command":40},"pnpm","pnpm dlx skills add Heesho\u002Fraffle-fun --skill cairo-vulnerability-scanner","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FDAYBREAK-TOB\u002Fattempt-02\u002Fruntime\u002Fcodex-home\u002Fplugins\u002Fcache\u002Ftrailofbits\u002Fbuilding-secure-contracts\u002F1.2.2\u002Fskills\u002Fcairo-vulnerability-scanner\u002FSKILL.md",true,[44,50,56],{"path":45,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":48,"sourceHtmlUrl":49},"agents\u002Fopenai.yaml","REFERENCE","参考文档",259,"https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FDAYBREAK-TOB\u002Fattempt-02\u002Fruntime\u002Fcodex-home\u002Fplugins\u002Fcache\u002Ftrailofbits\u002Fbuilding-secure-contracts\u002F1.2.2\u002Fskills\u002Fcairo-vulnerability-scanner\u002Fagents\u002Fopenai.yaml",{"path":51,"resourceType":52,"resourceTypeDesc":53,"sizeBytes":54,"sourceHtmlUrl":55},"assets\u002Ftrail-of-bits-mark.svg","ASSET","资产文件",3084,"https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FDAYBREAK-TOB\u002Fattempt-02\u002Fruntime\u002Fcodex-home\u002Fplugins\u002Fcache\u002Ftrailofbits\u002Fbuilding-secure-contracts\u002F1.2.2\u002Fskills\u002Fcairo-vulnerability-scanner\u002Fassets\u002Ftrail-of-bits-mark.svg",{"path":57,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":58,"sourceHtmlUrl":59},"resources\u002FVULNERABILITY_PATTERNS.md",21282,"https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FDAYBREAK-TOB\u002Fattempt-02\u002Fruntime\u002Fcodex-home\u002Fplugins\u002Fcache\u002Ftrailofbits\u002Fbuilding-secure-contracts\u002F1.2.2\u002Fskills\u002Fcairo-vulnerability-scanner\u002Fresources\u002FVULNERABILITY_PATTERNS.md",[61,68,75,82,87,94],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":18},"01M79XNCGXQ9R07VAPFB1H1WNF","spec-to-code-compliance","Check code against the documentation that specifies it - which requirements hold, which the code contradicts, which are absent, and what the code does that no document mentions. Use when comparing an implementation against a whitepaper, protocol spec, or design document.","https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FOPENAI-TOB\u002Fattempt-02\u002FS5\u002Fresources\u002Fskills\u002Fspec-to-code-compliance\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":18},"01M79XN7ADEZVW17912WC2CM7R","0xsimao-ai","Accounting-first smart contract security audit in the style of 0xSimao — maps the protocol's money model, then attacks it with 12 parallel lenses derived from his 869 published findings. Trigger on \"0xsimao ai\", \"0xsimao audit\", \"audit\", \"simao audit\", \"check this contract\", \"review for security\". Modes - default (full repo) or a specific filename.","https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FOPENAI-SIMAO\u002Fattempt-01\u002Fresources\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":18},"01M79XN26B8ZCW79FATC4TSXA5","solidity-auditor","Security audit of Solidity code while you develop. Trigger on \"audit\", \"check this contract\", \"review for security\", \"loop mode\", \"run the auditor in loop mode\", \"run 3 passes\". Modes - default (full repo) or a specific filename. Loop mode runs several passes in one scan, each pass told what the earlier ones found, and ends in one combined report; it remembers findings between scans in a ledger.","https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FOPENAI-PASHOV\u002Fattempt-01\u002Fharness-reference\u002FSKILL.md",[],[],{"skillNo":83,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":18},"01M79XMX0BKWJN0T8HZEBWTB6P","https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FDAYBREAK-TOB\u002Fattempt-02\u002Fruntime\u002Fcodex-home\u002Fplugins\u002Fcache\u002Ftrailofbits\u002Fspec-to-code-compliance\u002F2.0.2\u002Fskills\u002Fspec-to-code-compliance\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":18},"01M79XMM06CBG09CMZ5N8PGAZ1","entry-point-analyzer","Analyzes smart contract codebases to identify state-changing entry points for security auditing. Detects externally callable functions that modify state, categorizes them by access level (public, admin, role-restricted, contract-only), and generates structured audit reports. Excludes view\u002Fpure\u002Fread-only functions. Use when auditing smart contracts (Solidity, Vyper, Solana\u002FRust, Move, TON, CosmWasm) or when asked to find entry points, audit flows, external functions, access control patterns, or privileged operations.","https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FDAYBREAK-TOB\u002Fattempt-02\u002Fruntime\u002Fcodex-home\u002Fplugins\u002Fcache\u002Ftrailofbits\u002Fentry-point-analyzer\u002F1.0.4\u002Fskills\u002Fentry-point-analyzer\u002FSKILL.md",[],[],{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":18},"01M79XMCTG9288DZNAM1R3K2K2","ton-vulnerability-scanner","Scans TON (The Open Network) smart contracts for 3 critical vulnerabilities including integer-as-boolean misuse, fake Jetton contracts, and forward TON without gas checks. Use when auditing FunC contracts.","https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FDAYBREAK-TOB\u002Fattempt-02\u002Fruntime\u002Fcodex-home\u002Fplugins\u002Fcache\u002Ftrailofbits\u002Fbuilding-secure-contracts\u002F1.2.2\u002Fskills\u002Fton-vulnerability-scanner\u002FSKILL.md",[],[]]