0x-shashi/web3-audit-skills/starknet-scanner
Claude Code and agent skill by 0x-shashi/web3-audit-skills
- community
Checking that the SKILL.md file is still in the repository.
Use when the user wants to audit Starknet contracts for security vulnerabilities, scan Cairo contracts for Starknet-specific patterns including account abstraction, class replacement, or L1-L2 messaging, review Starknet DeFi protocols for component architecture flaws, or analyze cross-layer bridge security.
Install
npx vskill@latest install 0x-shashi/web3-audit-skills/starknet-scannerSKILL.md
The same SKILL.md was published earlier as 0x-shashi/web3-audit-skills/starknet-scanner.
Starknet Specialized Scanner
Specialized security scanner for Starknet Cairo contracts. Extends the general Cairo Scanner with Starknet-specific patterns: account abstraction, contract upgrades via replace_class, component architecture, and the L1-L2 messaging bridge.
Why a Separate Starknet Scanner?
While the Cairo Scanner covers language-level patterns (felt arithmetic, Sierra safety), Starknet-specific features create unique attack surfaces:
| Feature | Security Impact | |
|---|---|---|
| Account Abstraction | Custom validation logic = custom attack surface | |
replace_class_syscall | Contract upgrade mechanism — must be protected | |
| Components (like Solidity libraries) | Storage collision between components | |
| L1-L2 Messaging | Cross-chain replay, message validation | |
| Sequencer | Centralized sequencer = MEV, censorship risks | |
| Fee market | STRK token fees, gas estimation |
Detection Capabilities
| Category | Detection | Severity | |
|---|---|---|---|
| Account | __validate__ missing signature check | Critical | |
| Account | __execute__ allows arbitrary call without validation | Critical | |
| Account | Signature replay across chains (no chain_id in hash) | High | |
| Upgrade | replace_class_syscall callable by unauthorized party | Critical | |
| Upgrade | No upgrade delay/timelock | High | |
| Upgrade | Storage layout incompatibility after upgrade | High | |
| Components | Storage collision between components | High | |
| Components | Component events shadowing contract events | Medium | |
| L1-L2 | Message replay (consumed message not tracked) | Critical | |
| L1-L2 | Missing sender validation on L1 handler | Critical | |
| L1-L2 | Message not consumed (stuck funds) | High | |
| Felt | Felt arithmetic wrapping (p = 2^251 + 17*2^192 + 1) | High | |
| Storage | Storage address collision (Pedersen hash) | Medium | |
| Access | Missing caller validation on external function | Critical | |
| Access | Ownable component not initialized | High |
Starknet Account Abstraction
Every account on Starknet is a smart contract. This means custom validation logic:
Account Security Checklist
- [ ]
__validate__verifies transaction hash signature - [ ]
__validate__uses stored public key (not hardcoded) - [ ] Signature cannot be replayed (nonce handled by protocol)
- [ ]
chain_idincluded in signature verification (cross-chain replay) - [ ] Key rotation mechanism exists and is secure
- [ ] Multicall execution handles failures correctly (atomicity)
Contract Upgrade via replace_class_syscall
Starknet contracts can upgrade their logic using replace_class_syscall:
Upgrade Security
| Risk | Description | |
|---|---|---|
| Unauthorized upgrade | Anyone calling replace_class_syscall can change contract logic | |
| No timelock | Instant upgrade = no time for users to exit | |
| Storage incompatibility | New class may interpret storage differently | |
| Proxy pattern | If using proxy, verify replace_class on implementation, not just proxy |
- [ ]
replace_class_syscallprotected by access control (owner, governance) - [ ] Upgrade delay (timelock) implemented for critical contracts
- [ ] Storage layout documented and verified compatible across versions
- [ ] Upgrade event emitted
Component Architecture
Starknet components are reusable modules (similar to Solidity libraries with storage):
Component Security
| Risk | Description | |
|---|---|---|
| Storage collision | Two components writing to same storage address | |
| Uninitialized component | Ownable without initializer() = no owner set | |
| Event shadowing | Component events with same name as contract events | |
| Version mismatch | Component version incompatible with contract |
- [ ] All components initialized in constructor
- [ ]
#[substorage(v0)]used correctly (automatic storage isolation) - [ ] No manual storage access that could collide with component storage
- [ ] Component versions compatible with each other
L1-L2 Messaging
Starknet communicates with Ethereum L1 via asynchronous messaging:
| Direction | Mechanism | Latency | |
|---|---|---|---|
| L1 → L2 | send_message_to_l2() on Starknet Core contract | ~minutes (L2 block time) | |
| L2 → L1 | send_message_to_l1_syscall() in Cairo | ~hours (proof verification) |
L1-L2 Security Checklist
- [ ] L2 handler validates L1 sender (
from_addressin L1Handler) - [ ] L1 handler validates L2 sender (message origin)
- [ ] Messages consumed exactly once (replay protection)
- [ ] Message format matches between L1 and L2 contracts
- [ ] Stuck message handling (cancellation mechanism exists)
- [ ] Fee handling on L1→L2 messages correct
Resources
Workflows
See Also
- Cairo Scanner for Cairo language patterns
- Chain Guide: Starknet for chain context
Error Code Reference
Starknet-specific error codes and system errors encountered during audits.
Starknet OS / Sequencer Errors
| Error Code | Name | Meaning | |
|---|---|---|---|
TRANSACTION_FAILED | Transaction failure | Generic execution failure — check inner error | |
ENTRYPOINT_NOT_FOUND | Missing entrypoint | Selector not found on contract — wrong function name/args | |
UNINITIALIZED_CONTRACT | No contract | Address has no deployed contract class | |
ENTRY_POINT_FAILED | Execution revert | Contract function reverted — check custom error | |
FEE_TRANSFER_FAILURE | Fee payment | Insufficient balance to pay transaction fee | |
VALIDATE_FAILURE | Account validation | Account __validate__ rejected transaction — signature/auth issue | |
OUT_OF_RESOURCES | Resource limit | Transaction exceeded Cairo steps or builtins limit | |
CLASS_ALREADY_DECLARED | Duplicate class | Contract class hash already declared on network |
Account Abstraction Errors
| Error Pattern | Source | Meaning | |
|---|---|---|---|
'INVALID_SIGNATURE' | __validate__ | Signature verification failed in account contract | |
'INVALID_CALLER' | Account guard | Caller is not the expected account or protocol | |
'INVALID_TX_VERSION' | Version check | Transaction version not supported (v1 vs v3) | |
'EXPIRED' | Time check | Transaction or session expired | |
'UNDERSPENT_FEE' | Fee estimation | Actual fee lower than estimate — potential gas griefing | |
'PAYMASTER_REJECTED' | Paymaster | Paymaster refused to sponsor transaction |
Starknet Contract Errors (OpenZeppelin Cairo)
| Error String | Component | Meaning | |
|---|---|---|---|
'Caller is not the owner' | OwnableComponent | Missing owner role — access control | |
'Caller is the zero address' | OwnableComponent | Invalid zero caller | |
'New owner is the zero address' | OwnableComponent | Invalid ownership transfer | |
'ERC20: insufficient balance' | ERC20Component | Token balance too low | |
'ERC20: insufficient allowance' | ERC20Component | Approval not set | |
'ERC721: invalid token ID' | ERC721Component | Token does not exist | |
'ERC721: unauthorized caller' | ERC721Component | Not owner or approved | |
'ReentrancyGuard: reentrant call' | ReentrancyGuardComponent | Reentrancy detected | |
'Class hash cannot be zero' | UpgradeableComponent | Invalid upgrade target |
L1↔L2 Messaging Errors
| Error Pattern | Direction | Meaning | |
|---|---|---|---|
'INVALID_MESSAGE_TO_CONSUME' | L1→L2 | Message not found in L2 pending messages | |
'MESSAGE_NOT_SENT' | L2→L1 | L2 message not recorded by sequencer | |
'INVALID_FROM_ADDRESS' | L1→L2 | L1 sender address does not match expected | |
'INVALID_NONCE' | Both | Message nonce mismatch — replay or ordering issue |
Troubleshooting
| Issue | Likely Cause | Solution | |
|---|---|---|---|
| Account abstraction vulnerabilities missed | Scanner uses EOA mental model | Audit __validate__ and __execute__ in all account contracts; check signature schemes | |
replace_class upgrade risks not flagged | Scanner doesn't track class replacement | Map all replace_class_syscall calls; verify upgrade authority and timelock protections | |
| Component storage collision missed | Scanner doesn't model Cairo component storage | Verify component storage isolation; check for #[storage] field name conflicts across components | |
| L1↔L2 message handling gaps | Scanner audits L2 in isolation | Audit #[l1_handler] functions; trace message flow from L1 contract through Starknet OS | |
| Fee estimation manipulation not caught | Scanner doesn't model Starknet fee mechanism | Check __validate__ and __execute__ for fee-related assumptions; test with v3 transactions | |
| Missing event emission in state changes | Scanner focuses on logic, not observability | Verify all state-changing functions emit events; critical for off-chain indexing and monitoring |
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/starknet-scanner/SKILL.md
Popularity
- Repository stars
- 46
- Repository forks
- 6
- 7-day trend score
- 19
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 18 Mar 2026, 8 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/0x-shashi/web3-audit-skills/starknet-scanner)