Skip to content
Select theme

Beyond fuzzing: benchmarking smart contract security analysis

My MSc thesis in Cybersecurity at the University of Milan (supervisor: Prof. Andrea Lanzi, graduated 110/110 cum laude) benchmarks three analysis tools against real vulnerability patterns in Solidity smart contracts. The question is practical: if you hand a contract to a fuzzer and a symbolic executor, which bugs do they find, which do they miss, and why?

The benchmark framework, all contracts, scripts and raw results are public: sc-security-testing-benchmark.

Smart contracts are not regular software. Once deployed on Ethereum, the bytecode is immutable: there is no patch cycle, no hotfix, no rollback. If an attacker finds a flaw before the audit catches it, the exploit lands and the funds are gone. The attack surface is small (a few hundred lines of Solidity, typically) but the financial incentive is enormous, and every function is callable by anyone on the network.

The history speaks for itself:

Incident Year Root cause Loss
The DAO 2016 Reentrancy 3.6M ETH (~$60M)
Parity Wallet (July) 2017 Missing access modifier 150,000 ETH
Parity Wallet (November) 2017 selfdestruct on library contract 513,774 ETH frozen
BeautyChain (BEC) 2018 Integer overflow (batchTransfer) Token supply manipulation
Poly Network 2021 Cross-chain access control $611M
Nomad Bridge 2022 Permissionless replay $190M

Every one of these was exploitable by a pattern that automated tools can, in theory, detect. The thesis asks whether they actually do.

The benchmark targets three classes from the SWC Registry, chosen because they cover three fundamentally different analysis challenges: control-flow hijacking (reentrancy), arithmetic invariant violation (overflow), and semantic authorization gaps (access control).

The canonical smart contract bug. An external call hands execution to an untrusted contract before the caller updates its own state. The attacker’s fallback function re-enters the vulnerable function, which still sees the old (pre-withdrawal) balance.

The vulnerable pattern:

Vulnerable withdraw: state update after external call
function withdraw(uint amount) public {
require(balances[msg.sender] >= amount);
// External call BEFORE state update
(bool success, ) = msg.sender.call{value: amount}("");
require(success);
// This line executes too late: the attacker has already re-entered
balances[msg.sender] -= amount;
}

The attacker deploys a contract whose receive() function re-enters withdraw():

Reentrancy exploit contract
contract Attacker {
VulnerableBank target;
constructor(address _target) {
target = VulnerableBank(_target);
}
function attack() external payable {
target.deposit{value: msg.value}();
target.withdraw(msg.value);
}
receive() external payable {
if (address(target).balance >= 1 ether) {
target.withdraw(1 ether);
}
}
}

Each re-entry drains another 1 ether because balances[msg.sender] is never decremented until the entire call stack unwinds. The DAO lost 3.6 million ETH to exactly this pattern in 2016.

The fix is the Checks-Effects-Interactions (CEI) pattern: update state before making the external call. OpenZeppelin’s ReentrancyGuard adds a mutex as defense in depth:

Fixed: CEI pattern + ReentrancyGuard
function withdraw(uint amount) public nonReentrant {
require(balances[msg.sender] >= amount);
balances[msg.sender] -= amount; // state update FIRST
(bool success, ) = msg.sender.call{value: amount}("");
require(success);
}

Detection challenge. A fuzzer must generate a multi-contract transaction sequence where the attacker contract re-enters the victim. This requires ABI-aware seed generation and the ability to deploy auxiliary contracts during fuzzing. A symbolic executor can reason about the call graph statically but faces path explosion with nested re-entries.

The benchmark includes three reentrancy contracts of increasing complexity: reentrancy_simple (direct, single function), reentrancy_dao (DAO-style with mapping), and reentrancy_bonus (indirect reentrancy across two functions).

In Solidity versions before 0.8, arithmetic on unsigned integers wraps silently. A uint256 at its maximum value (2^256 - 1) overflows to 0 on increment. There is no exception, no revert, no signal.

Silent overflow in Solidity <0.8
uint256 a = type(uint256).max;
uint256 b = a + 1; // b == 0, silently

The real-world exploit that demonstrated the severity was batchTransfer in the BEC token (CVE-2018-10299). The function computes the total transfer amount by multiplying the number of recipients by the per-recipient value:

batchTransfer overflow (BEC/CVE-2018-10299 pattern)
function batchTransfer(address[] memory receivers, uint256 value) public {
uint256 amount = receivers.length * value; // overflow: 2 * (2^255) = 0
require(balances[msg.sender] >= amount); // passes: balance >= 0
balances[msg.sender] -= amount; // subtracts 0
for (uint i = 0; i < receivers.length; i++) {
balances[receivers[i]] += value; // adds 2^255 to each receiver
}
}

By choosing value = 2^255 and receivers.length = 2, the attacker makes amount overflow to 0. The require passes (any balance is >= 0), and each receiver gets 2^255 tokens minted from nothing.

Solidity 0.8+ added checked arithmetic by default: overflow reverts the transaction. Pre-0.8 code uses SafeMath. But a large share of deployed contracts predates 0.8, and unchecked blocks in post-0.8 code reintroduce the risk wherever gas optimization is prioritized over safety.

Detection challenge. For a fuzzer, overflow is an arithmetic property: the tool must either instrument the EVM to detect wrapping or check for it explicitly via a dedicated oracle. A symbolic executor encodes the overflow condition as a constraint and asks the SMT solver whether the path is satisfiable, which is a natural fit for this class.

The benchmark includes three overflow contracts: integer_overflow_1 (direct addition), integer_overflow_mul (multiplication), and overflow_single_tx (overflow triggerable in a single transaction).

Authorization bugs in smart contracts are subtle because Solidity provides no built-in role system. Developers enforce access control through custom modifiers and require checks. A missing check, a wrong comparison, or a confused identity primitive opens the contract to unauthorized state changes.

The tx.origin vs msg.sender confusion is the textbook case:

tx.origin phishing vulnerability
function transfer(address to, uint amount) public {
require(tx.origin == owner); // WRONG: checks the EOA that started the tx chain
payable(to).transfer(amount);
}

tx.origin is the externally-owned account (EOA) that initiated the entire transaction chain. msg.sender is the immediate caller. If the owner interacts with a malicious contract, that contract can call transfer(): msg.sender would be the malicious contract’s address (and would fail the check), but tx.origin is still the owner’s EOA (so the check passes).

The phishing attack:

tx.origin phishing exploit
contract PhishingAttack {
VulnerableWallet target;
address attacker;
constructor(address _target) {
target = VulnerableWallet(_target);
attacker = msg.sender;
}
// Owner is tricked into calling this (e.g., via a fake airdrop claim)
function claim() external {
// tx.origin == owner, so the require passes
target.transfer(attacker, address(target).balance);
}
}

Another pattern: constructors with the wrong name. Before Solidity 0.4.22 introduced the constructor keyword, the constructor was a function with the same name as the contract. A typo meant the “constructor” was a regular public function, callable by anyone after deployment:

Incorrect constructor name (pre-0.4.22 pattern)
contract Owned {
address public owner;
// Should be "Owned()" to act as constructor
// "owned()" (lowercase) is just a public function anyone can call
function owned() public {
owner = msg.sender;
}
}

Detection challenge. Access control bugs are semantic: the code “works” (no crash, no revert), but the authorization logic is wrong. There is no universal structural pattern to match. A tool must either know the intended access policy or detect that a state-changing function lacks a sender check. The thesis demonstrates that this is the hardest class for all three tools.

The benchmark includes three access control contracts: unprotected0 (missing modifier on a critical function), phishable (tx.origin instead of msg.sender), and incorrect_constructor_name1 (constructor naming bug).

The three tools represent three fundamentally different approaches to finding bugs in smart contracts. Understanding how each one works at the engine level explains why they succeed and fail where they do.

Smartian (written in F#/.NET) generates random transaction sequences, executes them against the contract, and uses coverage feedback to guide mutation toward unexplored code paths. It operates in three phases:

  1. Seed generation. ABI-aware construction of initial transaction sequences. Smartian parses the contract ABI and generates transactions with type-correct arguments rather than mutating raw bytes.
  2. Execution and coverage. Each sequence runs in an instrumented EVM. Smartian tracks two coverage metrics: branch coverage (standard control-flow edges) and data-flow coverage (def-use pairs on state variables). A sequence that hits new coverage is added to the corpus.
  3. Mutation. Seeds are mutated at the transaction level (reorder, add, remove transactions) and at the argument level (type-aware value mutations). Data-flow feedback guides which arguments to mutate: if a state variable influences a branch condition, Smartian prioritizes mutations that change that variable.

Strengths: Fast iteration (thousands of sequences per second), minimal setup (takes the ABI and bytecode, no specification needed), effective at reaching deep code through incremental coverage gain.

Limitations: Purely syntactic. Smartian has no understanding of what a bug “means.” It detects only violations it is hardcoded to check for (assertion failures, reentrancy via call-graph analysis). If the EVM does not revert and no hardcoded oracle fires, the bug is invisible.

Mythril: symbolic execution with SMT constraint solving

Section titled “Mythril: symbolic execution with SMT constraint solving”

Mythril (Python) does not execute the contract. It builds a symbolic representation of all execution paths through the EVM bytecode and encodes them as constraints for the Z3 SMT solver. For each path, Z3 determines whether a set of inputs exists that reaches a vulnerable state.

  1. Bytecode disassembly. Mythril takes compiled EVM bytecode (not source code) and builds a control-flow graph.
  2. Symbolic exploration (LASER engine). The LASER engine walks the CFG symbolically, maintaining symbolic state for the stack, memory, and storage. Each branch creates a fork with the branch condition added as a constraint.
  3. Detection modules. At each explored state, Mythril runs detection modules that check for known vulnerability patterns (e.g., reentrancy: CALL opcode with symbolic ETH value followed by SSTORE; integer overflow: arithmetic operation where the Z3 model allows wrapping).
  4. Constraint solving. When a detection module triggers, Z3 checks satisfiability. If satisfiable, Mythril reports the bug with a concrete input that triggers it.

Strengths: Sound reasoning about path reachability: if Z3 says a path is reachable, it is. Can reason about conditions that would take a fuzzer astronomical time to hit by chance. Produces concrete trigger inputs as proof.

Limitations: Path explosion: the number of paths grows exponentially with branches and loop iterations. The 600-second timebox means Mythril explores only a fraction of the state space on complex contracts. Slow compared to fuzzing (seconds to minutes per analysis versus milliseconds per fuzz iteration). Detection is limited to its built-in modules: a vulnerability class with no matching module is invisible.

ItyFuzz: snapshot-based fuzzing with runtime oracles

Section titled “ItyFuzz: snapshot-based fuzzing with runtime oracles”

ItyFuzz (Rust) addresses the fundamental bottleneck of smart contract fuzzing: maintaining state across long transaction sequences. Traditional fuzzers must replay the entire sequence from genesis to reach a deep state. ItyFuzz snapshots the EVM state at interesting points and starts new fuzz campaigns from those snapshots.

  1. Snapshot management. After each transaction, ItyFuzz evaluates whether the resulting state is “interesting” (new coverage, new dataflow patterns). Interesting states are snapshotted and added to a pool.
  2. Waypoints. Dataflow-guided waypoints identify state transitions that are likely prerequisites for reaching deeper bugs. ItyFuzz prioritizes exploration from these waypoints.
  3. Runtime bug oracles. Instead of relying on hardcoded checks in the EVM, ItyFuzz defines runtime oracles that observe execution traces and flag anomalies. Oracles exist for reentrancy (recursive call detection), selfdestruct reachability, and specific dangerous call patterns.

Strengths: Extremely fast time-to-discovery on bugs that its oracles cover. Snapshot reuse avoids the replay overhead that slows traditional sequence-based fuzzers. The reentrancy oracle is particularly effective (100% detection in the benchmark).

Limitations: Oracle-dependent. If no oracle exists for a vulnerability class, ItyFuzz cannot detect it even if it reaches the vulnerable state. The benchmark demonstrates this definitively for integer overflow (zero detection across all 15 runs) and partially for access control.

The benchmark uses contracts from SmartBugs-Curated, a labeled dataset of vulnerable Solidity contracts. Nine vulnerable contracts were selected across the three target classes:

Category Contract Vulnerability
Reentrancy reentrancy_simple Direct single-function reentrancy
Reentrancy reentrancy_dao DAO-style reentrancy with mapping
Reentrancy reentrancy_bonus Indirect reentrancy across two functions
Overflow integer_overflow_1 Direct addition overflow
Overflow integer_overflow_mul Multiplication overflow
Overflow overflow_single_tx Single-transaction overflow trigger
Access control unprotected0 Missing access modifier on critical function
Access control phishable tx.origin instead of msg.sender
Access control incorrect_constructor_name1 Constructor naming bug (pre-0.4.22)

Three control contracts (known-safe) measure false positive rates:

Contract Source Purpose
ERC20 OpenZeppelin Standard token, no known vulnerabilities
GuardTest OpenZeppelin ReentrancyGuard Correct reentrancy protection
MyVault Custom (CEI pattern) Correct withdraw with state-first update

Each tool runs 5 times on each of the 9 vulnerable contracts plus the 3 controls, for a total of 180 runs (60 per tool). For the vulnerable set alone, 135 runs (9 contracts x 3 tools x 5 runs). The timebox is 600 seconds per run for fuzzers (Smartian, ItyFuzz). Mythril runs to completion or hits the 600-second cap.

Metrics:

  • Detection rate. Binary FOUND/NOT-FOUND per run, aggregated with Wilson 95% confidence intervals.
  • Time-to-discovery (TTD). Seconds from tool start to first bug report. For fuzzers, this is wall-clock time to the first detection event. For Mythril, this is the time to complete analysis and produce the report.
  • False positive rate. Average number of spurious issues reported on the control set per run.

Hardware: WSL2 on Windows 11, Intel Core Ultra 7 155H (Meteor Lake), 32 GB DDR5, NVMe SSD.

Tool Category Runs TP Detection rate Wilson 95% CI
Smartian Reentrancy 15 10 66.7% 41.7 - 84.8
Smartian Arithmetic 15 15 100% 79.6 - 100
Smartian Access control 15 10 66.7% 41.7 - 84.8
Mythril Reentrancy 15 15 100% 79.6 - 100
Mythril Arithmetic 15 15 100% 79.6 - 100
Mythril Access control 15 5 33.3% 15.2 - 58.3
ItyFuzz Reentrancy 15 15 100% 79.6 - 100
ItyFuzz Arithmetic 15 0 0% 0.0 - 20.4
ItyFuzz Access control 15 5 33.3% 15.2 - 58.3
Contract Smartian (5 runs) Mythril (5 runs) ItyFuzz (5 runs)
reentrancy_simple 5/5 5/5 5/5
reentrancy_dao 5/5 5/5 5/5
reentrancy_bonus 0/5 5/5 5/5
integer_overflow_1 5/5 5/5 0/5
integer_overflow_mul 5/5 5/5 0/5
overflow_single_tx 5/5 5/5 0/5
unprotected0 0/5 0/5 0/5
phishable 5/5 5/5 0/5
incorrect_constructor_name1 5/5 0/5 5/5
Contract Smartian Mythril ItyFuzz
reentrancy_simple 0.20 18.03 0.00
reentrancy_dao 0.04 22.35 0.00
reentrancy_bonus ND 31.15 0.00
integer_overflow_1 0.00 7.16 ND
integer_overflow_mul 0.00 7.01 ND
overflow_single_tx 0.00 66.55 ND
unprotected0 ND ND ND
phishable 0.00 23.15 ND
incorrect_constructor_name1 0.02 ND 1.00

ND = not detected.

Contract Smartian (avg/run) Mythril (avg/run) ItyFuzz (avg/run)
ERC20 (OpenZeppelin) 0.0 0 0
MyVault (CEI pattern) 0.0 7 0
GuardTest (ReentrancyGuard) 0.2 4 0

Mythril reports 7 issues on a correct CEI implementation and 4 on a contract protected by ReentrancyGuard. These are false positives from its reentrancy detection module, which flags the structural pattern (external call after storage read) without verifying whether the state update ordering actually prevents exploitation.

Five findings emerge from the results that matter for anyone choosing or building smart contract analysis tools.

1. Reaching the bug is not the same as recognizing it

Section titled “1. Reaching the bug is not the same as recognizing it”

ItyFuzz achieves 100% detection on reentrancy because its dedicated oracle watches for recursive call patterns during execution and fires immediately. On integer overflow, it detects nothing (0/15 runs), despite almost certainly reaching the vulnerable arithmetic during fuzzing.

The problem is not coverage. ItyFuzz explores states aggressively through snapshot reuse and reaches deep execution paths faster than any tool in the benchmark. The problem is that it has no oracle for overflow: the EVM completes the wrapping arithmetic without error, ItyFuzz observes no anomaly, and the bug goes unreported.

Reaching a vulnerable state is a necessary condition for detection, not a sufficient one. Without an oracle (or a specification) that defines what “wrong” looks like, the tool cannot distinguish a correct execution from a catastrophic one.

2. Semantic bugs resist all automated analysis

Section titled “2. Semantic bugs resist all automated analysis”

unprotected0 (a function missing its access control modifier) was detected by no tool across all 45 runs. The function executes correctly: it does not revert, overflow, or trigger any structural anomaly. The bug is that anyone can call it, but “anyone should not be able to call this” is a semantic property that requires knowledge of the intended access policy.

This is not a tool failure in the usual sense. It is an epistemological limit of code-only analysis: not all vulnerabilities are inferable from the code alone without a specification. Property-based testing (Echidna, Foundry invariant tests) addresses this by letting the developer encode the intended invariants, but that requires manual effort and domain knowledge that no fully automated tool provides.

3. The speed-depth tradeoff is real and asymmetric

Section titled “3. The speed-depth tradeoff is real and asymmetric”

Fuzzers detect bugs in sub-second time. Smartian’s median TTD for overflow contracts is 0.00s, meaning within the first fuzz iteration. ItyFuzz detects reentrancy at 0.00s across all three contracts. Mythril takes 7 to 67 seconds depending on the contract.

But Mythril catches reentrancy_bonus (indirect reentrancy across two functions) where Smartian fails entirely (0/5), and it catches phishable (tx.origin confusion) where ItyFuzz scores 0/5.

The asymmetry matters: you cannot compensate for missing oracles by running a fuzzer longer. Smartian’s failure on reentrancy_bonus is not a coverage problem. 600 seconds is enough time for a greybox fuzzer to explore the state space many times over. It is a limitation of its reentrancy detection heuristic, which does not handle the indirect case. Running for 6000 seconds would not help.

Mythril’s strength is the opposite: if the bug falls within a detection module’s pattern and the path is reachable within the exploration budget, Z3 will find a satisfying input regardless of how unlikely it would be to hit by random generation.

The per-contract table makes this visible at a glance:

  • Smartian misses reentrancy_bonus and unprotected0
  • Mythril misses incorrect_constructor_name1 and unprotected0
  • ItyFuzz misses all three overflow contracts, phishable, and unprotected0

Every tool has blind spots determined by its detection capabilities, not its exploration power. A security assessment that relies on a single automated tool will miss vulnerabilities that another tool in the same timebox would catch. The practical consequence: tool composition (running multiple tools on the same codebase) is not a nice-to-have, it is a requirement for any audit that claims thoroughness.

5. A control set exposes the cost of false positives

Section titled “5. A control set exposes the cost of false positives”

ItyFuzz produces zero false positives across all control contracts. Smartian produces a near-zero rate (0.2 average issues on GuardTest, likely an edge case in its heuristic). Mythril produces 11 false positives per control run (7 on MyVault, 4 on GuardTest).

Mythril’s false positives come from its reentrancy detection module flagging structural patterns that match the vulnerable template but are actually safe because the state update ordering prevents exploitation. In a real audit pipeline, these false positives consume analyst time: every reported issue must be triaged manually. A tool that finds one more true positive but generates ten more false positives may cost more total effort than a tool that misses the bug entirely.

Approach Speed Depth Setup cost Best for
Coverage-guided fuzzing (Smartian) High Low to medium Low (ABI + bytecode) Fast first pass, arithmetic bugs, standard reentrancy
Symbolic execution (Mythril) Low High Low (bytecode) Complex control flow, indirect reentrancy, path-dependent bugs
Snapshot-based fuzzing (ItyFuzz) High Medium Low (ABI + bytecode) Reentrancy (dedicated oracle), fast state exploration
Property-based testing (Echidna, Foundry) Medium High if well specified High (requires invariants) Semantic bugs, access control, custom business logic
Hybrid (fuzzing + symbolic execution) Medium to high High Medium Comprehensive coverage when tool composition is automated

For a security assessment in practice:

  1. Run Smartian and ItyFuzz in parallel for fast, low-cost coverage of arithmetic and reentrancy bugs.
  2. Run Mythril for path-dependent bugs and as a second opinion on control-flow vulnerabilities.
  3. Write property-based tests (Echidna or Foundry invariant tests) for access control logic and custom business rules. This is the only reliable approach for semantic bugs that no pattern-matching tool catches.
  4. Treat the combined output as a starting point for manual review, not a final verdict.

The benchmark maps the current boundaries. Four lines of work could shift them:

LLM-assisted analysis. Large language models can read Solidity source and reason about developer intent, potentially bridging the gap between code-only analysis and specification-based testing. A model that understands “this function should only be callable by the owner” could generate the properties that Echidna needs, lowering the manual cost of property-based testing from “requires a security engineer who knows the codebase” to “requires a review of generated properties.”

Invariant testing at scale. Foundry’s invariant testing and Echidna’s property-based approach catch semantic bugs that all three benchmark tools miss. The barrier is writing good invariants. Automated invariant generation (from documentation, from common patterns, from LLM suggestions) could make this practical at audit scale rather than limiting it to high-value engagements.

Runtime verification. Tools like Scribble (by ConsenSys Diligence) instrument Solidity source with runtime assertions derived from a formal specification language. This turns specification violations into runtime failures that any fuzzer can catch, combining the depth of specification-based reasoning with the speed of fuzzing.

Hybrid pipelines. The data argues strongly for tool composition. An automated pipeline that runs fuzzers for fast coverage, symbolic execution for depth, and property-based tests for semantics, with results merged and deduplicated, could approach the detection coverage that manual auditing provides at a fraction of the cost and time.