caracal: Static Analyzer for Starknet smart contracts

Caracal

Caracal is a static analyzer tool over the SIERRA representation for Starknet smart contracts.

Features

  • Detectors to detect vulnerable Cairo code
  • Printers to report information
  • Taint analysis
  • Data flow analysis framework
  • Easy to run in Scarb projects

Detectors

Num Detector What it Detects Impact Confidence
1 controlled-library-call Library calls with a user-controlled class hash High Medium
2 unchecked-l1-handler-from Detect L1 handlers without from address check High Medium
3 reentrancy Detect when a storage variable is read before an external call and written after Medium Medium
4 unused-events Events defined but not emitted Medium Medium
5 unused-return Unused return values Medium Medium
6 unenforced-view Function has view decorator but modifies state Medium Medium
7 unused-arguments Unused arguments Low Medium
8 reentrancy-benign Detect when a storage variable is written after an external call but not read before Low Medium
9 reentrancy-events Detect when an event is emitted after an external call leading to out-of-order events Low Medium
10 dead-code Private functions never used Low Medium

Printers

  • cfg: Export the CFG of each function in a .dot file
  • callgraph: Export function call graph to a .dot file

Install & Use

Copyright (C) 2023 crytic