Cairo smart contract audit: what Starknet adds to the review
A Cairo smart contract audit checks the logic of a Starknet contract plus the risks Starknet adds: arithmetic on the felt252 type, messages between Ethereum and Starknet, and signature replay under Starknet account abstraction. Four of the six Cairo pitfalls in the Trail of Bits catalog are about messaging between L1 and L2. QuillShield audits Solidity today, so for Cairo code request a manual audit from QuillAudits.
QuillShield doesn't support Cairo today. It audits Solidity in Foundry projects. For Cairo code, request a manual audit from QuillAudits.
What does a Cairo audit cover that an EVM audit doesn't?
The core of the review is familiar: who can call each function, what state changes before each external call, how each price is read and which way each division rounds. Starknet adds three areas an EVM review doesn't have to think about in the same way: the felt252 field element as a number type, contracts on Ethereum and Starknet that send each other messages, and accounts that are contracts with their own signature rules.
Trail of Bits keeps a short catalog of known Cairo pitfalls in its not so smart contracts collection. The table follows it, with a plain explanation of each entry and the page that covers the same mechanics in Solidity.
| Pitfall | What goes wrong | What to check |
|---|---|---|
Arithmetic overflow with felt252 |
Arithmetic on the felt252 type is insecure: a balance or amount kept as a felt can overflow or underflow without the revert a Solidity 0.8 developer expects. |
Which values are stored or computed as felt252, and could any of them be an amount? |
| Unchecked from address in the L1 handler | An l1_handler that doesn't check who sent the message on Ethereum lets any L1 contract trigger it. |
Does every L1 handler compare from_address with the one expected L1 contract? |
| L1 to L2 address conversion | Addresses crossing from Ethereum need checks before Starknet code acts on them. | Is every address in a message checked to be a valid L2 address before use? |
| L1 to L2 message failure | A message sent from Ethereum may not be processed by the sequencer, so funds locked on L1 wait on a message that never lands. | If the L2 side never runs, what happens to the funds the user locked, and can they be reclaimed? |
| Overconstrained L1 and L2 interaction | Checks that differ between the two sides can block one direction, a denial of service. | Does every message the L1 side accepts also pass the checks on the L2 side, and the reverse? |
| Signature replay | Account abstraction means each contract must carry its own replay protection for signed messages. | Does each signed message carry a nonce, the chain and the contract it is meant for? |
Why is felt252 arithmetic a risk?
felt252 is a field element rather than a fixed-width integer, and Trail of Bits lists insecure arithmetic on the felt252 type as the first Cairo pitfall. A developer coming from Solidity 0.8 expects an underflow to revert, but a felt that holds an amount gives no such protection, so a subtraction can turn a small balance into a number near the top of the field.
Keep amounts out of felt252, use it for identifiers and hashes, and test every boundary of the arithmetic that remains. The Cairo scanner skill from Trail of Bits lists this pattern first among the six it checks.
What can go wrong between Ethereum and Starknet?
A Starknet bridge or any contract that takes messages from Ethereum has two halves: a Solidity contract on L1 that sends or receives messages, and a Cairo contract on L2 with an l1_handler that acts on them. Four of the six catalog entries sit on that seam:
- Who sent it. The L1 handler must check
from_address, or any Ethereum contract can send it a message that mints, releases funds or changes settings. - Whose address it is. An address that comes across from Ethereum needs checking before the Cairo side treats it as a Starknet account.
- Whether it lands. A message from L1 may not be processed by the sequencer, so the design needs a path for funds whose message never executes.
- Whether both sides agree. If the L1 contract accepts what the L2 contract rejects, or the reverse, one direction of the bridge stops working.
The Solidity half of that seam is EVM code. The bridge audit page covers what to check in it, including message validation, replay and upgrades.
What happened at zkLend?
| Protocol | zkLend |
|---|---|
| Date | 12 February 2025 |
| Chain | Starknet |
| Loss | $9.57M according to rekt.news, about $10M according to BlockSec |
| What happened | The zkLend market for wstETH was empty. The attacker used the donation path in flash_loan() to push the lending accumulator of that market from 1.0 to 851.0 in one transaction, then exploited division that truncated when share tokens were minted and burned to withdraw more than they had deposited. The zkLend post-mortem called the three design details involved, deposits into empty markets, accepted donations and withdrawal rounding, individually harmless. |
| Sources | BlockSec, rekt.news, DL News |
The BlockSec post-mortem dates the attack to 12 February 2025 and traces it to the accumulator and the truncating division, and rekt.news gives the jump in the accumulator from 1.0 to 851.0 and the $9.57M figure. In June 2025 zkLend announced it would wind down, with about $200,000 left in its treasury to support affected users, as DL News reported.
The zkLend mechanism is the same one behind the ERC-4626 inflation attack and the rounding errors that hit Solidity lending markets, which is why a Cairo audit reads the accounting as closely as the Starknet-specific code.
Which tools exist for Cairo security?
- Caracal: Trail of Bits' static analyzer for Cairo.
- Cairo/StarkNet vulnerability scanner: a Claude Code skill from Trail of Bits, part of its Building Secure Contracts plugin, that checks Cairo contracts for the six catalog patterns, reports a coverage table and can run Caracal.
- cairo-security: a review skill from the keep-starknet-strange/starknet-agentic repository, drawn from over 50 public audit reports. It is meant as a review pass after your contract compiles and tests pass, and says it is not a replacement for a professional audit.
- Starknet Foundry: the test framework (
snforge) that the cairo-security skill targets, at version 0.56.0, with Scarb 2.15.1 as the build tool.
Scanners and skills check known patterns, but deciding whether the two halves of a bridge agree on every message, or whether an empty market can be pushed into rounding that favors the attacker, still takes a reviewer who reads both sides.
Can QuillShield audit Cairo?
QuillShield does not audit Cairo today. It supports Solidity, for Foundry projects, and its full audit and pull request checks don't cover Cairo. For a Starknet codebase, request a manual audit from QuillAudits, the audit firm that makes QuillShield, which has audited 1,500+ protocols since 2018. QuillAudits clients include Taiko, StarkWare, Celo, Metis, ZetaChain, BrahmaFi, Tria and Almanak.
If your system has a Solidity contract on Ethereum that sends or receives Starknet messages, the Solidity audit page covers what QuillShield checks on that side. AI audit vs manual audit covers how the two kinds of review split the work.
Talk to an auditor about the scope and timing of a manual Cairo audit.
What should you check before a Cairo audit?
- Which values are kept as
felt252, and is any of them an amount or a balance? - Does every
l1_handlercheckfrom_addressagainst the one L1 contract it trusts? - Is every address that crosses from Ethereum checked before the L2 side uses it?
- If an L1 message never executes on L2, how do users get their funds back?
- Do the L1 and L2 sides apply the same limits and checks to the same message?
- Does every signed message carry a nonce, the chain and the contract it is meant for?
- Can an empty market or vault be pushed by a donation into rounding that favors the caller?
FAQ
Do Starknet contracts need a different audit from EVM contracts?
They need the same logic review plus three more areas: felt252 arithmetic, messaging between Ethereum and Starknet, and replay protection under account abstraction, which together make up the six pitfalls in the Trail of Bits Cairo catalog.
What should a Starknet bridge check first?
Check first that every l1_handler compares from_address with the one L1 contract it trusts. Trail of Bits lists an unchecked from address in the L1 handler as an access control issue, because without the check any Ethereum contract can send the handler a message.
Can an AI tool audit Cairo code?
Agent skills exist for Cairo, such as Trail of Bits' scanner and the cairo-security skill, which says it is not a replacement for a professional audit. QuillShield does not support Cairo today.
Does QuillShield support Cairo?
QuillShield supports Solidity in Foundry projects today, so for Cairo on Starknet, request a manual audit from QuillAudits.
Sources
- Not so smart contracts: Cairo, Trail of Bits checked 3 December 2026
- Cairo/StarkNet vulnerability scanner, Trail of Bits checked 3 December 2026
- cairo-security skill, keep-starknet-strange checked 3 December 2026
- zkLend exploit post-mortem: unraveling the details of the $10M flash loan attack, BlockSec checked 3 December 2026
- zkLend: Rekt, rekt.news checked 3 December 2026
- DeFi protocol zkLend shuts down four months after $9M hack, DL News checked 3 December 2026
- Caracal, Trail of Bits
- Starknet Foundry, Starknet Foundry
- Scarb, Software Mansion