Efficiently Detecting Reentrancy Vulnerabilities in Complex Smart Contracts

Zexu Wang, Jiachi Chen, Yanlin Wang, Yu Zhang, Weizhe Zhang, Zibin Zheng

Abstract

Reentrancy vulnerabilities remain one of the most critical security threats in the smart contract ecosystem, often resulting in significant financial losses. While numerous detection tools exist, they frequently struggle with the complexity of real-world decentralized applications (DApps), which involve intricate cross-contract logic and dynamic jump addresses known as "orphan jumps." This paper introduces SliSE, a novel framework that combines inter-contract program slicing with advanced symbolic execution. By utilizing an Inter-contract Program Dependency Graph (I-PDG) to prune irrelevant code and Static Single Assignment (SSA) to resolve orphan jumps, SliSE achieves a breakthrough in detection performance. On complex real-world datasets, SliSE achieved an F1 score of 78.65%, outperforming state-of-the-art tools by over 69% while maintaining high efficiency.

1. Introduction: The Challenge of Complex Reentrancy

Reentrancy is a semantic vulnerability where a contract makes an external call to an untrusted contract before completing its own state updates. This allows an attacker to "re-enter" the calling contract and execute logic (such as withdrawals) multiple times before the state reflects the first transaction. The standard defense is the Check-Effect-Interaction (C-E-I) pattern, which dictates that all internal state changes must occur before external interactions.

Illustration of a reentrancy vulnerability flow violating the Check-Effect-Interaction pattern.

However, modern smart contracts are rarely isolated. They interact across multiple contracts, creating complex dependency chains that standard static analysis tools often fail to capture. Furthermore, compilers often generate dynamic jump addresses—"orphan jumps"—that lack a preceding PUSH opcode, effectively breaking the Control Flow Graph (CFG) and leaving automated tools blind to critical execution paths.

2. Methodology: The SliSE Framework

SliSE (Slicing + Symbolic Execution) employs a two-stage pipeline designed to balance the speed of static analysis with the precision of symbolic execution.

Stage I: Warning Search via Program Slicing

To avoid the "path explosion" problem common in symbolic execution, SliSE first prunes the search space. It constructs an Inter-contract Program Dependency Graph (I-PDG) that maps data and control dependencies across contract boundaries. Using backward slicing starting from sensitive sinks (like call.value), the tool extracts only the code paths relevant to potential reentrancy. This stage identifies potential C-E-I violations and generates preliminary warnings.

Stage II: Symbolic Execution Verification

In the second stage, SliSE verifies the reachability of the warnings generated in Stage I. A key innovation here is the use of Static Single Assignment (SSA) and constant propagation to resolve orphan jumps. By tracking variable definitions back through the CFG, SliSE can determine the intended targets of dynamic jumps, thereby recovering missing edges in the contract's logic map. Finally, the Z3 solver is used to determine if the constraints along a path are mathematically satisfiable, confirming the presence of a vulnerability.

3. Experimental Evaluation

The researchers evaluated SliSE against eight state-of-the-art tools, including Mythril, Slither, and Securify, across three distinct datasets:

  • DB1 (Complex Contracts): 895 vulnerabilities from 1,322 real-world audit reports. These contracts are significantly more complex than standard benchmarks, averaging 25 times more lines of code.
  • DB2 (Ethereum Mainnet): Over 230,000 verified contracts from Etherscan.
  • DB3 (SmartBugs): A standard benchmark of 143 simpler contracts.

Key Results

SliSE demonstrated a massive leap in performance on complex code. On the DB1 dataset, it achieved an F1 score of 78.65%, whereas the next best tool (Mythril) scored only 9.26%. This disparity highlights the failure of existing tools to handle real-world DApp complexity. Despite the use of symbolic execution, SliSE remained highly efficient, reducing average detection time from 157 seconds to just 25 seconds through its aggressive slicing approach.

4. Discussion and Limitations

The primary insight of this work is that symbolic execution is only viable for complex contracts when preceded by effective pruning. By focusing on the semantic violation of the C-E-I pattern rather than just syntax, SliSE provides a more robust detection mechanism.

However, the tool currently faces challenges with "No Economic Loss" designs. These are contracts where a reentrancy path exists, but the contract's balance is depleted or transferred in a way that prevents actual financial theft. SliSE currently lacks the deep economic semantic analysis required to distinguish these harmless instances from exploitable vulnerabilities.

5. Conclusion

SliSE represents a significant advancement in smart contract security. By integrating inter-contract slicing with SSA-based path recovery, it successfully bridges the gap between theoretical vulnerability detection and the practical demands of auditing complex, real-world DApps. Future developments will focus on extending this framework to other vulnerability classes and incorporating economic modeling to further reduce false positives.

Summary updated

BibTeX
@article{wang2024efficiently,
  author = {Zexu Wang and Jiachi Chen and Yanlin Wang and Yu Zhang and Weizhe Zhang and Zibin Zheng},
  title = {{Efficiently Detecting Reentrancy Vulnerabilities in Complex Smart Contracts}},
  journal = {Proc. ACM Softw. Eng.},
  year = {2024},
  doi = {10.1145/3643734},
}
Figure