@trailofbits

Creator · trailofbits

Last updated · Aug 24, 2026

cairo-vulnerability-scanner

REVIEW · 69Registry indexed

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.

OpenAgentSkill Trust Score
69/100

Sandbox only

Quality85/100
Audit84/100
Stars6.8K
Verified installs0

Install targets

Codex install prompt

Install the "cairo-vulnerability-scanner" agent skill from https://github.com/trailofbits/skills/tree/main/plugins/building-secure-contracts/skills/cairo-vulnerability-scanner. Read its SKILL.md or equivalent instructions first, install only the files needed for this workspace, and summarize any required setup before using it. Skill purpose: 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. After the install attempt, report the result to https://www.openagentskill.com/api/agent/outcome with POST JSON {"event_id":"install_<unique-id>","skill_slug":"trailofbits-cairo-vulnerability-scanner","task":"Install cairo-vulnerability-scanner","agent":"codex","outcome":"success","install_used":true}. Replace event_id with a unique value and outcome with success or failed. Report success only after the skill is installed and a minimal verification passes.

Supply asset profile

Coding and developer agents

Code review, repo analysis, testing, CI, GitHub, DevOps, and developer workflow skills.

Browse track

Scenario

GitHub automation

I need my agent to triage GitHub issues, review pull requests, and summarize repository changes.

Agent fit

Claude Code + CLI + Codex

Codex, Claude Code, Cursor, CLI, or custom agents.

Install

Ready

npx skills add trailofbits/skills --skill cairo-vulnerability-scanner

Maintenance

fresh

Pushed today

Risk

Risky

Financial research output is not financial advice; require human review before any live investment decision

GitHub quality

6.8K

85/100 Quality · 77/100 Trust

Coverage tags

CodingGitHub automationsecurityagent-skill

Review notes

Financial research output is not financial advice; require human review before any live investment decision · Potential broker, wallet, exchange, or real-money execution surface; sandbox and explicit approval are required

Agent adoption scorecard

Trust, audit, and install readiness at a glance

These scores combine public repository metadata, OpenAgentSkill review signals, maintenance freshness, and install readiness. They are a shortlist signal, not a replacement for human review.

Quality

Excellent
85

High-confidence pick with strong adoption and healthy maintenance signals.

Trust

Sandbox only
69

Useful candidate with missing or mixed trust signals. Keep it in an isolated workspace until the outcome loop proves task fit.

Audit

Risky
84

A machine-readable review of install readiness, security metadata, maintenance, and adoption risk.

OpenAgentSkill Trust Score v5

Sandbox only

Run only in a sandbox and compare close alternatives before using it for real work.

CodexClaude CodeCursorOpenAgentSkill CLI

Stars

6.8K GitHub stars

Repo activity

6.8K stars, 585 forks

Maintenance

Pushed today

License

CC-BY-SA-4.0

Install

npx skills add trailofbits/skills --skill cairo-vulnerability-scanner

Install safety

standard package or runtime install path

Permission surface

shell or command execution, filesystem or document access

Agent outcomes

No agent outcome data yet

Docs

Strong README/SKILL.md context

Risk summary

Review before production

  • SKILL.md does not explicitly list its own limitations (e.g., that it focuses on Cairo 1.x and may miss issues outside the six patterns).
  • Financial research output is not financial advice; require human review before any live investment decision.
  • This skill may touch real-money trading, broker, wallet, or exchange operations; use only in a sandbox with explicit approval.
  • Quality score needs review

Install readiness

Install path available

  • Install path is available
  • Repository evidence is available
  • License is declared
  • No Agent Proven outcome evidence yet

Agent-readable metadata

Machine-readable decision data for this skill.

Use this block or the embedded JSON to decide whether an agent should install this skill, choose an alternative, or ask for human review first.

View technical data+

Suited tasks

  • GitHub automation workflows
  • Claude Code teams
  • teams that value GitHub adoption signals
  • Inspect repository metadata

Suited agents

CodexClaude CodeCursorOpenAgentSkill CLICLI

Install decision

Command
npx skills add trailofbits/skills --skill cairo-vulnerability-scanner
Policy
block
Human review
yes

Trust and risk

Trust
69/100
Audit
84/100
Risk level
Risky

Outcome loop

Endpoint
/api/agent/outcome
Event ID
resolve
Outcomes
5

Install command

npx skills add trailofbits/skills --skill cairo-vulnerability-scanner

Do not use when

  • teams that need a vendor-supported SLA
  • production agents without a repository review
  • SKILL.md does not explicitly list its own limitations (e.g., that it focuses on Cairo 1.x and may miss issues outside the six patterns).
  • Audit risk risky exceeds max_risk=medium
  • High-risk permission hints: Shell or command execution

Agent safety v2

56/100 · Avoid automatic install

Blocked for auto-installblock

This skill should not be selected by an agent without explicit human security review.

Do not auto-install. Inspect the source, dependencies, and permission surface first.

Resolve via API

high

Shell or command execution

Skill metadata references terminal, CLI, shell, subprocess, or command execution workflows.

medium

Network access

Skill likely fetches remote pages, APIs, repositories, or external services.

medium

Filesystem access

Skill may read or write project files, documents, generated artifacts, or local workspace state.

  • Audit risk risky exceeds max_risk=medium
  • High-risk permission hints: Shell or command execution
  • Financial research output is not financial advice; require human review before any live investment decision

Agent resolve plan

Let an agent verify fit before installing.

The Resolve API returns the selected skill, alternatives, safety policy, audit notes, install target, and copy-paste prompt an agent can follow without scraping this page.

Open text plan

Agent should check

  • Task fit and alternatives from Resolve API.
  • Audit score, trust score, and safety policy warnings.
  • Install target compatibility for Codex, Claude Code, Cursor, or CLI.

Copy prompt

Task: Use cairo-vulnerability-scanner in this workspace.
Resolve first: https://www.openagentskill.com/api/agent/resolve?task=Use%20cairo-vulnerability-scanner%20for%20an%20agent%20workflow&agent=codex&max_risk=medium
Review install handoff: https://www.openagentskill.com/api/skills/trailofbits-cairo-vulnerability-scanner/install
Install command: npx skills add trailofbits/skills --skill cairo-vulnerability-scanner
Before running it, summarize audit warnings, required permissions, and the fallback skill if install is risky.

Agent handoff

Give an agent the install path, not another directory page.

Use the public install endpoint to fetch the command, safety checklist, target prompts, and canonical links for this skill.

Open install API

Agent prompt

Use cairo-vulnerability-scanner for this task. Review https://www.openagentskill.com/api/skills/trailofbits-cairo-vulnerability-scanner/install, then install with: npx skills add trailofbits/skills --skill cairo-vulnerability-scanner

Registry metadata

Agent-readable profile for automatic skill selection.

This page exposes the same decision, trust, audit, use-case, and install signals through the Registry API, so agents can rank this skill without scraping the UI.

Open manifest

Agent fit

96/100

GitHub automation

Platforms

Claude Code

Audit report

Risky · 84/100

A machine-readable review of install readiness, security metadata, maintenance, and adoption risk.

View audit reportView eval report

Agent decision cockpit

Primary pick for GitHub automation

Use this as a leading candidate, then validate the README and install path in your own agent stack.

96
Readiness
Adopt
Stage

Role in stack

Primary pick

Primary fit

GitHub automation

Trust label

Production-ready

Install path

Command ready

Use when

  • GitHub automation workflows
  • Claude Code teams
  • teams that value GitHub adoption signals

Evidence

  • 6,823 GitHub stars
  • recent repository activity
  • install command or GitHub repo available
  • 85/100 quality profile
  • 1 OpenAgentSkill engagement events

review first

  • SKILL.md does not explicitly list its own limitations (e.g., that it focuses on Cairo 1.x and may miss issues outside the six patterns).

Implementation path

  1. 1Install it in a sandbox agent and run one GitHub automation task end to end.
  2. 2Compare output quality, latency, and failure behavior against at least one alternative.
  3. 3Promote it into production only after reviewing repository permissions, license, and maintenance signals.

Trust profile

Sandbox only

Useful candidate with missing or mixed trust signals. Keep it in an isolated workspace until the outcome loop proves task fit.

69
OpenAgentSkill Trust Score

GitHub adoption

PASS

6.8K GitHub stars

Stars/forks activity

PASS

6.8K stars, 585 forks; issue activity unavailable in current metadata

Recent maintenance

PASS

Pushed today

License clarity

PASS

CC-BY-SA-4.0

Good signals

  • AI review approved
  • Install path is available
  • Repository evidence is available
  • Recently maintained repository
  • Large GitHub adoption signal
  • Install command has no obvious high-risk pattern
  • Outcome loop is ready but needs first real agent run

Review before install

  • SKILL.md does not explicitly list its own limitations (e.g., that it focuses on Cairo 1.x and may miss issues outside the six patterns).
  • Financial research output is not financial advice; require human review before any live investment decision.
  • This skill may touch real-money trading, broker, wallet, or exchange operations; use only in a sandbox with explicit approval.
  • Quality score needs review
  • No real agent outcome reports yet
  • Human review required before unattended installation

Recommended action

Run only in a sandbox and compare close alternatives before using it for real work.

Quality profile

Excellent candidate for agent workflows

High-confidence pick with strong adoption and healthy maintenance signals.

85
GitHub stars
6.8K
Freshness
Today
Install ready
Yes
License
CC-BY-SA-4.0
Review before install: SKILL.md does not explicitly list its own limitations (e.g., that it focuses on Cairo 1.x and may miss issues outside the six patterns).

Workflow fit

Use this skill in these scenarios

Workflow fit

Add it to a complete workflow

Alternative shortlist

Compare before you install

Similar skills that may fit this task.

Compare all

Overview

--- name: cairo-vulnerability-scanner description: 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. ---

# 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 ```rust // 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 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](resources/VULNERABILITY_PATTERNS.md).

### Pattern Summary:

1. **Unchecked Arithmetic** ⚠️ CRITICAL - Integer overflow/underflow in felt252 2. **Storage Collision** ⚠️ CRITICAL - Conflicting storage variable hashes 3. **Missing Access Control** ⚠️ CRITICAL - No caller validation on sensitive functions 4. **Improper Felt252 Boundaries** ⚠️ HIGH - Not validating felt252 range 5. **Unvalidated Contract Address** ⚠️ HIGH - Using untrusted contract addresses 6. **Missing Caller Validation** ⚠️ CRITICAL - No get_caller_address() checks

For complete vulnerability patterns with code examples, see [VULNERABILITY_PATTERNS.md](resources/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 ```bash # 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: - [ ] L1 validates address < STARKNET_FIELD_PRIME - [ ] L1 implements message cancellation - [ ] L2 validates from_address in handlers - [ ] Symmetric access controls L1 ↔ L2 - [ ] Test full roundtrip flows

### Step 6: Static Analysis with Caracal ```bash # Run Caracal detectors caracal detect src/

# Specific detectors caracal detect src/ --detectors unchecked-felt252-arithmetic caracal detect src/ --detectors unchecked-l1-handler-from caracal detect src/ --detectors missing-nonce-validation ```

---

## 8. Reporting Format

### Finding Template ````markdown ## [CRITICAL] Unchecked from_address in L1 Handler

**Location**: `src/bridge.cairo:145-155` (handle_deposit function)

**Description**: The `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.

**Vulnerable Code**: ```rust // bridge.cairo, line 145 #[l1_handler] fn handle_deposit( ref self: ContractState, from_address: felt252, // Not validated! user: ContractAddress, amount: u256 ) { let current_balance = self.balances.read(user); self.balances.write(user, current_balance + amount); } ```

**Attack Scenario**: 1. Attacker deploys malicious L1 contract 2. Malicious contract calls `starknetCore.sendMessageToL2(l2Contract, selector, [attacker_address, 1000000])` 3. L2 handler processes message without checking sender 4. Attacker receives 1,000,000 tokens without depositing any funds 5. Protocol suffers infinite mint vulnerability

**Recommendation**: Validate `from_address` against authorized L1 bridge: ```rust #[l1_handler] fn handle_deposit( ref self: ContractState, from_address: felt252, user: ContractAddress, amount: u256 ) { // Validate L1 sender let authorized_l1_bridge = self.l1_bridge_address.read(); assert(from_address == authorized_l1_bridge, 'Unauthorized L1 sender');

let current_balance = self.balances.read(user); self.balances.write(user, current_balance + amount); } ```

**References**: - building-secure-contracts/not-so-smart-contracts/cairo/unchecked_l1_handler_from - Caracal detector: `unchecked-l1-handler-from` ````

---

## 9. Priority Guidelines

### Critical (Immediate Fix Required) - Unchecked from_address in L1 handlers (infinite mint) - L1-L2 address conversion issues (funds to zero address)

### High (Fix Before Deployment) - Felt252 arithmetic overflow/underflow (balance manipulation) - Missing signature replay protection (replay attacks) - L1-L2 message failure without cancellation (locked funds)

### Medium (Address in Audit) - Overconstrained L1-L2 interactions (trapped funds)

---

## 10. Testing Recommendations

### Unit Tests ```rust #[cfg(test)] mod tests { use super::*;

#[test] fn test_felt252_overflow() { // Test arithmetic edge cases }

#[test] #[should_panic] fn test_unauthorized_l1_handler() { // Wrong from_address should fail }

#[test] fn test_signature_replay_protection() { // Same signature twice should fail } } ```

### Integration Tests (with L1) ```rust // Test full L1-L2 flow #[test] fn test_deposit_withdraw_roundtrip() { // 1. Deposit on L1 // 2. Wait for L2 processing // 3. Verify L2 balance // 4. Withdraw to L1 // 5. Verify L1 balance restored } ```

### Caracal CI Integration ```yaml # .github/workflows/security.yml - name: Run Caracal run: | # Rebuilds from source each run; cache ~/.cargo or pin a release binary instead. cargo install --git https://github.com/crytic/caracal --profile release --force caracal detect src/ --fail-on high,critical ```

---

## 11. Additional Resources

- **Building Secure Contracts**: `building-secure-contracts/not-so-smart-contracts/cairo/` - **Caracal**: https://github.com/crytic/caracal - **Cairo Documentation**: https://book.cairo-lang.org/ - **StarkNet Documentation**: https://docs.starknet.io/ - **OpenZeppelin Cairo Contracts**: https://github.com/OpenZeppelin/cairo-contracts

---

## 12. Quick Reference Checklist

Before completing Cairo/StarkNet audit:

**Arithmetic Safety (HIGH)**: - [ ] No felt252 used for balances/amounts (use u128/u256) - [ ] OR felt252 arithmetic has explicit bounds checking - [ ] Overflow/underflow scenarios tested

**L1 Handler Security (CRITICAL)**: - [ ] ALL `#[l1_handler]` functions validate `from_address` - [ ] from_address compared against stored L1 contract address - [ ] Cannot bypass by deploying alternate L1 contract

**L1-L2 Messaging (HIGH)**: - [ ] L1 bridge validates addresses < STARKNET_FIELD_PRIME - [ ] L1 bridge implements message cancellation - [ ] L2 handlers check from_address - [ ] Symmetric validation rules L1 ↔ L2 - [ ] Full roundtrip flows tested

**Signature Security (HIGH)**: - [ ] Signatures include nonce tracking - [ ] Nonce incremented after each use - [ ] Domain separator includes chain ID and contract address - [ ] Signature replay tested and prevented - [ ] Cross-chain replay prevented

**Tool Usage**: - [ ] Caracal scan completed with no critical findings - [ ] Unit tests cover all vulnerability scenarios - [ ] Integration tests verify L1-L2 flows - [ ] Testnet deployment tested before mainnet

Technical details

Version
1.0.0
License
CC-BY-SA-4.0
Last updated
Aug 24, 2026
Published
Aug 24, 2026

Decision snapshot

Primary pick

96
Ready
Adopt
Stage

6,823 GitHub stars

Audit

Install review

Install and adoption review

84
Risky
Security
78/100
Maintenance
100/100
Install
92/100
Open full auditView eval report

Agent-proven evidence

Agent-proven evidence

Outcome reports after resolve, review, install, and one narrow run.

0
Proven
Needs first agent runAuto-install: review firstLast: Unknown
Success rate
Recent failure
Outcomes
0
Output quality
Failed
0
Not relevant
0
Installs
0
Risk blocked
0
Setup needed
0
Production
0

No agent outcome data yet. The first agent run can report success, setup needs, risk blocks, failure, or not-relevant through /api/agent/outcome.

Install

Add to agent workflow

Free and open source. Review the report before installing into production agents.

Growth loop

Share kit

X

Scenario-led draft for cairo-vulnerability-scanner, ready for a manual X post.

Curator note
cairo-vulnerability-scanner: Scans Cairo/StarkNet smart contracts for 6 critical vulnerabilities including felt252 arithme...

6.8K stars

https://www.openagentskill.com/skills/trailofbits-cairo-vulnerability-scanner?ref=x
Open X draft
Optional reply with install command
Listing + install path for cairo-vulnerability-scanner:
https://www.openagentskill.com/skills/trailofbits-cairo-vulnerability-scanner?ref=x

Install: npx skills add trailofbits/skills --skill cairo-vulnerability-scanner

Listing source

Registry indexed

Claimable

This listing was indexed from public sources and is not marked official until a maintainer claim is approved.

Indexed by
OpenAgentSkill community index

Attribution links to the public repository or creator profile. Creators can claim the listing to update ownership signals.

Claim this skill

Owner claim

Claim this skill listing

This Registry indexed listing is attributed to trailofbits but is not marked official yet. Claim it to add a verified owner signal and make future launch, install, and audit updates easier to trust.

Creator backlink kit

Add the evidence badges to your README

Show the canonical listing, current trust and audit signals, and real Agent-Proven evidence where developers evaluate the repository.

[![Listed on OpenAgentSkill](https://www.openagentskill.com/api/badge/trailofbits-cairo-vulnerability-scanner?metric=listed&label=Listed)](https://www.openagentskill.com/skills/trailofbits-cairo-vulnerability-scanner)
[![OpenAgentSkill Trust](https://www.openagentskill.com/api/badge/trailofbits-cairo-vulnerability-scanner?metric=trust&label=Trust)](https://www.openagentskill.com/skills/trailofbits-cairo-vulnerability-scanner)
[![OpenAgentSkill Audit](https://www.openagentskill.com/api/badge/trailofbits-cairo-vulnerability-scanner?metric=audit&label=Audit)](https://www.openagentskill.com/skills/trailofbits-cairo-vulnerability-scanner/audit)
[![Agent Proven](https://www.openagentskill.com/api/badge/trailofbits-cairo-vulnerability-scanner?metric=proven&label=Agent%20Proven)](https://www.openagentskill.com/skills/trailofbits-cairo-vulnerability-scanner)

Author

T

trailofbits

@trailofbits

Platform fit

Health signals

GitHub stars
6.8K
Quality score
50/100
Last GitHub push
Aug 24, 2026
Framework hints
Unknown
OpenAgentSkill views
1
Install copies
0
Outbound clicks
0

Community signal

Share whether this skill looks useful for your agent workflow. Aggregated feedback improves rankings over time.

Trust & safety

Sandbox only

69
  • GitHub adoption6.8K GitHub starsPASS
  • Stars/forks activity6.8K stars, 585 forks; issue activity unavailable in current metadataPASS
  • Recent maintenancePushed todayPASS
  • License clarityCC-BY-SA-4.0PASS
  • README/SKILL.md completenessMetadata includes enough usage and workflow contextPASS
  • Dependency/runtime riskcommand execution surfaceINFO