मुख्य सामग्री पर जाएँ
Skillpedia
सिक्योरिटी8.0k · #12658

cairo-vulnerability-scanner

यह क्या करती है

StarkNet के Cairo कोड में ज्ञात कमज़ोरियाँ जाँचती है, जैसे अंकगणित ओवरफ़्लो, परतों के बीच असुरक्षित मैसेज और सिग्नेचर रीप्ले। यह StarkNet प्रोजेक्ट पर काम करने वाले डेवलपर्स और ऑडिटर्स के लिए है।

कब इस्तेमाल करें

  • ✓जब कोई ऑडिटर Cairo में लिखे StarkNet प्रोजेक्ट की समीक्षा करता है।
  • ✓जब कोई डेवलपर StarkNet पर L1 से L2 ब्रिज या मैसेज हैंडलर की जाँच करता है।
  • ✓जब कोई टीम लॉन्च से पहले Cairo कॉन्ट्रैक्ट में सिग्नेचर जाँच की समीक्षा करती है।

Skill का लिंक

https://github.com/trailofbits/skills/blob/main/plugins/building-secure-contracts/skills/cairo-vulnerability-scanner/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/trailofbits/skills/blob/main/plugins/building-secure-contracts/skills/cairo-vulnerability-scanner/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“लॉन्च से पहले मेरे StarkNet के Cairo कॉन्ट्रैक्ट में ओवरफ़्लो और सिग्नेचर की समस्याएँ जाँचिए।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

यह स्किल Cairo और StarkNet के लिए छह खास पैटर्न खोजती है, जैसे felt252 अंकगणित, एड्रेस कन्वर्ज़न और L1 हैंडलर। यह जो मिलता है उसकी रिपोर्ट देती है और हर एक को समझाती है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

Cairo/StarkNet Vulnerability Scanner

1. Purpose

Systematically 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/StarkNet ecosystem.

2. When to Use This Skill

  • Auditing StarkNet smart contracts (Cairo)
  • Reviewing L1-L2 bridge implementations
  • Pre-launch security assessment of StarkNet applications
  • Validating cross-layer message handling
  • Reviewing signature verification logic
  • Assessing L1 handler functions

3. Platform Detection

File Extensions & Indicators

  • Cairo files: .cairo

Language/Framework Markers

// Cairo contract indicators
#[contract]
mod MyContract {
    use starknet::ContractAddress;

    #[storage]
    struct Storage {
        balance: LegacyMap<ContractAddress, felt252>,
    }

    #[external(v0)]
    fn transfer(ref self: ContractState, to: ContractAddress, amount: felt252) {
        // Contract logic
    }

    #[l1_handler]
    fn handle_deposit(ref self: ContractState, from_address: felt252, amount: u256) {
        // L1 message handler
    }
}

// Common patterns
felt252, u128, u256
ContractAddress, EthAddress
#[external(v0)], #[l1_handler], #[constructor]
get_caller_address(), get_contract_address()
send_message_to_l1_syscall

Project Structure

  • src/contract.cairo - Main contract implementation
  • src/lib.cairo - Library modules
  • tests/ - Contract tests
  • Scarb.toml - Cairo project configuration

Tool Support

  • Caracal: Trail of Bits static analyzer for Cairo
  • Installation: cargo install --git https://github.com/crytic/caracal --profile release --force (a Rust tool — not on PyPI)
  • Usage: caracal detect src/
  • cairo-test: Built-in testing framework
  • Starknet Foundry: Testing and development toolkit

4. How This Skill Works

When invoked, I will:

  1. Search your codebase for Cairo files
  2. Analyze each contract for the 6 vulnerability patterns
  3. Report findings with file references and severity, above them a coverage table carrying a verdict for every pattern
  4. Provide fixes for each identified issue
  5. Check L1-L2 interactions for messaging vulnerabilities

5. Example Output

When vulnerabilities are found, you'll get a report like this:

=== CAIRO/STARKNET VULNERABILITY SCAN RESULTS ===

6. Vulnerability Patterns (6 Patterns)

I check for 6 critical vulnerability patterns unique to Cairo/Starknet. For detailed detection patterns, code examples, mitigations, and testing strategies, see VULNERABILITY_PATTERNS.md.

Pattern Summary:

  1. Felt252 Arithmetic Overflow/Underflow ⚠️ HIGH - felt252 wraps silently; use u128/u256
  2. L1 to L2 Address Conversion ⚠️ HIGH - L1 address not validated against STARKNET_FIELD_PRIME
  3. L1 to L2 Message Failure ⚠️ HIGH - No cancellation path when a message cannot be consumed
  4. Overconstrained L1 <-> L2 Interaction ⚠️ MEDIUM - Coupling that can strand funds or block progress
  5. Signature Replay Protection ⚠️ HIGH - No nonce, or a domain separator missing chain/contract
  6. Unchecked from_address in L1 Handler ⚠️ CRITICAL - Any L1 contract can drive the handler

For complete vulnerability patterns with code examples, see VULNERABILITY_PATTERNS.md.

7. Scanning Workflow

Step 1: Platform Identification

  1. Verify Cairo language and StarkNet framework
  2. Check Cairo version (Cairo 1.0+ vs legacy Cairo 0)
  3. Locate contract files (src/*.cairo)
  4. Identify L1-L2 bridge contracts (if applicable)

Step 2: Arithmetic Safety Sweep

# Find felt252 usage in arithmetic
rg "felt252" src/ | rg "[-+*/]"

# Find balance/amount storage using felt252
rg "felt252" src/ | rg "balance|amount|total|supply"

# Should prefer u128, u256 instead

Step 3: L1 Handler Analysis

For each #[l1_handler] function:

  • Validates from_address parameter
  • Checks address != zero
  • Has proper access control
  • Emits events for monitoring

Step 4: Signature Verification Review

For signature-based functions:

  • Includes nonce tracking
  • Nonce incremented after use
  • Domain separator includes chain ID and contract address
  • Cannot replay signatures

Step 5: L1-L2 Bridge Audit

If contract includes bridge functionality:

अक्सर पूछे जाने वाले सवाल

अंकगणित की जाँच क्या देखती है?

यह felt252 नंबर टाइप वाले अंकगणित की जाँच करती है, जो ओवरफ़्लो हो सकता है अगर कोड उसे संभालता न हो।

क्या यह ब्रिज को भी कवर करती है?

हाँ। यह L1 से L2 मैसेजिंग और L1 हैंडलर फ़ंक्शन को भी कवर करती है।

क्या यह सिर्फ़ ऑडिटर्स के लिए है?

नहीं। डेवलपर्स भी ऑडिट से पहले अपना Cairo कोड जाँचने के लिए इसका इस्तेमाल कर सकते हैं।

जानकारी

लेखक का मूल विवरण

Scans Cairo/StarkNet 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.

repo: trailofbits/skills

लोकप्रियता

GitHub स्टार
8.0k
रैंकिंग में स्थान
#12658
लाइसेंस
CC-BY-SA-4.0
अपडेट की गई
2/11/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

audit-context-building

8.0k

यह आपके एजेंट को सुरक्षा जाँच से पहले किसी अनजान कोड को समझने में मदद करती है, हर फ़ंक्शन की मान्यताएँ और निर्भरताएँ नक्शे में दिखाकर।

कोडिंगसिक्योरिटी

algorand-vulnerability-scanner

8.0k

यह आपके एजेंट को Algorand कॉन्ट्रैक्ट्स में 11 आम सुरक्षा समस्याएँ जाँचने में मदद करती है, जैसे रीकीइंग हमले और बिना जाँची फ़ीस।

कोडिंगसिक्योरिटी

audit-prep-assistant

8.0k

यह आपके एजेंट को बाहरी सुरक्षा समीक्षा के लिए कोड तैयार करने में मदद करती है, जैसे स्टैटिक एनालिसिस, टेस्ट कवरेज और दस्तावेज़ीकरण।

कोडिंगसिक्योरिटी

code-maturity-assessor

8.0k

यह आपके एजेंट को स्मार्ट कॉन्ट्रैक्ट या ब्लॉकचेन कोडबेस को 9 परिपक्वता क्षेत्रों में आँकने में मदद करती है, सबूतों और सुधारों की प्राथमिकता सूची के साथ।

कोडिंगसामान्य कोडिंग

मिलती-जुलती skills