Introduction
Smart contracts on the Ethereum blockchain are immutable, handle significant financial assets, and operate in an inherently adversarial environment. Vulnerabilities, such as the infamous DAO hack, can lead to irreversible catastrophic losses. Despite their importance, analyzing these contracts is difficult due to the low-level nature of Ethereum Virtual Machine (EVM) bytecode, complex dynamic control flows (e.g., dynamic jumps), and an unknown execution environment where external contracts' code is often unavailable at analysis time.
Existing tools typically fall into two categories: manual interactive frameworks that require expert-level proofs, or automated "bug finders" that rely on heuristics. While fast, these automated tools are often "unsound," meaning they suffer from false negatives and provide no formal guarantees that a contract is truly secure. eThor addresses this gap as the first automated static analyzer for EVM bytecode that is provably sound.
Methodology: Provably Sound Abstraction
The core of eThor is a sound reachability analysis based on Constrained Horn Clauses (CHCs). The tool translates the complex semantics of EVM bytecode into a set of Horn clauses that over-approximate the contract's behavior.
This formal abstraction ensures that if a "bad state"—representing a security vulnerability—is unreachable in the abstract model, it is guaranteed to be unreachable in any real execution. To bridge the gap between theoretical logic and executable code, the authors developed HoRSt, a high-level specification language. HoRSt allows researchers to define Horn-clause abstractions which are then automatically compiled into optimized SMT-LIB code for solvers like Z3.
Handling Reentrancy: Two-Level Callstack Modeling
A major technical contribution of eThor is its novel approach to modeling reentrancy, a common source of vulnerabilities where a contract calls an external party which then calls back into the original contract before the first execution finishes.
eThor utilizes a two-level callstack abstraction to distinguish between the "initial" execution and "reentering" executions. This model carefully tracks how persistent storage propagates between these states. By reducing complex properties like "single-entrancy" to simple reachability queries (e.g., "Is it possible to reach a CALL instruction while a previous call to the same contract is still pending?"), eThor can formally verify reentrancy resistance.
The analysis pipeline is multi-staged: it first reconstructs the control-flow graph (CFG) using the high-performance Datalog engine Soufflé, followed by a more expensive, value-sensitive analysis in Z3.
Evaluation and Key Results
The authors evaluated eThor against the official EVM test suite (604 tests) and a benchmark of 720 distinct real-world bytecodes.
- 100% Recall: In a head-to-head comparison with ZEUS (a previous state-of-the-art tool), eThor achieved 100% recall, finding all vulnerabilities where ZEUS only identified 11.4%.
- Superior Accuracy: eThor achieved an F-measure of 89%, significantly outperforming ZEUS's 20.4%.
- Practicality: Despite its formal rigor, eThor successfully terminated on 95.4% of real-world contracts, demonstrating its viability for large-scale analysis.
- Functional Verification: Beyond bug finding, eThor proved functional correctness for the SafeMath library, identifying runtime assertion checks that were mathematically redundant and could be removed to save gas.
Insights and Limitations
eThor demonstrates that automation and formal soundness are not mutually exclusive. A key insight was the necessity of "Horn clause folding"—merging sequential execution steps into single logical implications—to achieve performance. However, the authors found that "linear folding" was often more effective than "exhaustive folding," highlighting the value of the flexible HoRSt framework for optimization experimentation.
Currently, eThor operates in a "standalone" setting, over-approximating the behavior of all external contracts. This can lead to false positives in complex multi-contract scenarios. Additionally, it does not yet support DELEGATECALL or CALLCODE to unknown addresses, as these allow external code to modify a contract's storage directly, complicating sound analysis. Future work aims to extend eThor to handle relational properties and automate the generation of analysis patterns directly from concrete semantics.
Summary updated