# cairo-vulnerability-scanner

cairo-vulnerability-scanner — a skill that scans Cairo contracts on StarkNet for 6 vulnerability patterns, from felt252 overflow to replayed signatures. Use it when auditing L1-L2 bridges.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 5700 installs · ★ 8341 repo stars
- Author: trailofbits
- License: CC-BY-SA-4.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/trailofbits/skills/tree/HEAD/plugins/building-secure-contracts/skills/cairo-vulnerability-scanner/SKILL.md
- Updated: 2026-10-24
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/cairo-vulnerability-scanner

## What it does

The skill walks through the `.cairo` files in a project and checks each contract against 6 StarkNet-specific vulnerability patterns. They include silent `felt252` wraparound, replayable signatures, an L1 address never compared with `STARKNET_FIELD_PRIME`, and L1 to L2 messages with no way to cancel. The worst one, an unchecked `from_address` in an `#[l1_handler]`, is rated `CRITICAL`. The others are `HIGH` or `MEDIUM`.

It works in steps: identify the Cairo version and contract files, search for `felt252` in arithmetic with `rg`, go through every L1 handler, review nonces and domain separators in signature code, audit the bridge, then run `caracal detect src/`. Each finding comes with a file location and a suggested fix.

Before the findings, the report shows a coverage table where all 6 patterns get a verdict, even those that turned up nothing. So a quiet pattern never reads as a clean contract. The static analysis step needs Caracal installed first: it is a Rust tool, installed with `cargo`, not from PyPI.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add trailofbits/skills --skill cairo-vulnerability-scanner -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/cairo-vulnerability-scanner/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/cairo-vulnerability-scanner/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add trailofbits/skills --skill cairo-vulnerability-scanner -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/cairo-vulnerability-scanner/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add trailofbits/skills --skill cairo-vulnerability-scanner -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/cairo-vulnerability-scanner/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install trailofbits/skills plugins/building-secure-contracts/skills/cairo-vulnerability-scanner
```

2. **Manually: put the files in place**
- File: `.github/skills/cairo-vulnerability-scanner/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add trailofbits/skills --skill cairo-vulnerability-scanner -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/trailofbits/skills --path plugins/building-secure-contracts/skills/cairo-vulnerability-scanner
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/cairo-vulnerability-scanner/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add trailofbits/skills --skill cairo-vulnerability-scanner -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/trailofbits/skills/tree/HEAD/plugins/building-secure-contracts/skills/cairo-vulnerability-scanner/SKILL.md

## When to use it
- find `felt252` balances that wrap silently
- check that every `#[l1_handler]` validates `from_address`
- confirm signatures cannot be replayed
- review an L1-L2 bridge before launch
- get a suggested fix for each finding

## Example prompts
- Scan the Cairo contracts in `src/` with cairo-vulnerability-scanner
- Audit this StarkNet bridge: check every `#[l1_handler]` and the message cancellation path
- Check the signature code in my `.cairo` files for nonce and domain separator problems

## Similar
- [upgrade-cairo-contracts](https://affpapa.org/en/nevibecode/skills/upgrade-cairo-contracts.md) — skill · 234 installs
- [develop-secure-contracts](https://affpapa.org/en/nevibecode/skills/develop-secure-contracts.md) — skill · 610 installs
- [OpenZeppelin Cairo Contracts](https://affpapa.org/en/nevibecode/mcp/openzeppelin-cairo-contracts.md) — MCP server
- [vulnerability-scanner](https://affpapa.org/en/nevibecode/skills/vulnerability-scanner.md) — skill · 1300 installs
- [Python Security Vulnerability Auditor (OWASP-Mapped & Production-Hardened)](https://affpapa.org/en/nevibecode/prompts/python-security-vulnerability-auditor-owasp-mapped-production-hardened.md) — prompt · ★ 178201 repo stars
- [dependency-vulnerability-triage](https://affpapa.org/en/nevibecode/skills/dependency-vulnerability-triage.md) — skill · 296 installs

From the same set: [trailofbits/skills](https://affpapa.org/en/nevibecode/by/trailofbits/skills.md) — 95 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
