SmartState: Detecting State-Reverting Vulnerabilities in Smart Contracts via Fine-Grained State-Dependency Analysis

Zeqin Liao, Sicheng Hao, Yuhong Nan, Zibin Zheng

TL;DR

SmartState is a novel static analysis framework designed to detect State-Reverting Vulnerabilities (SRVs) in Solidity smart contracts. By combining bytecode analysis with historical transaction data to build a fine-grained state-dependency graph, it identifies how attackers can exploit the blockchain's "rollback" mechanism to manipulate contract states for illegal profit or to trigger Denial-of-Service (DoS) attacks.

What Problem Does This Paper Address?

In Solidity, the revert, require, and assert statements are used for error handling and access control. If a condition isn't met, the entire transaction is rolled back to its original state. While this ensures atomicity, it creates a unique attack surface: an adversary can "preview" the outcome of a transaction and, if the result is unfavorable (e.g., losing a bet in a gambling DApp), trigger a revert to undo the loss.

The authors identify these as State-Reverting Vulnerabilities (SRVs). Existing security tools often struggle with SRVs because they either focus on different languages (like WASM), look for narrow symptoms like gas exhaustion, or fail to capture the complex "state dependencies" between different functions. For example, a vulnerability might exist because a state variable set in one function is used as a security check in another, but current tools miss this logical link.

Methods

SmartState introduces a Fine-Grained State-Dependency Analysis that operates at the bytecode level. Its workflow consists of four main stages:

  1. ASD Extraction (Assertion-related State Dependency): The tool identifies dependencies created by require or assert statements. If Function A writes to a variable that Function B uses in a security check, an ASD link is established.
  2. TSD Extraction (Temporal-ordered State Dependency): This is a standout feature. Since static analysis cannot always predict the intended order of function calls, SmartState uses a Finite State Machine (FSM) to learn the "normal" sequence of transactions from historical blockchain data.
  3. SDG Construction: It merges traditional data-flow and control-flow dependencies with the newly extracted ASD and TSD links to create a comprehensive State-Dependency Graph (SDG).
  4. Vulnerability Detection: Using the SDG, SmartState performs taint analysis. it looks for "SRV indicators"—sensitive states that are non-deterministic (e.g., relying on randomness) and lack proper access control—and checks if an external attacker can reach and manipulate them.

Datasets

The researchers evaluated SmartState using two primary datasets:

  • $D_{srv}$ (Manual-labeled Dataset): A ground-truth collection of 91 SRVs across 47 real-world contracts. This includes 17 vulnerabilities from public attack reports and 74 identified through manual audits of popular financial DApps.
  • $D_{large}$ (Large-scale Dataset): An open dataset containing 47,351 real-world smart contracts used to test the tool's effectiveness "in the wild."

Key Insights and Ideas

  • Reverts as Control Flow: The paper treats the state-reverting mechanism not just as an error handler, but as a fundamental control flow primitive that attackers can weaponize.
  • Bridging Static and Historical Analysis: Pure static analysis often lacks context. By incorporating historical transaction traces (TSD), SmartState gains an understanding of how a contract is actually used, allowing it to find logical dependencies that aren't explicitly coded in a single function.
  • The Power of ASD: The evaluation showed that ignoring assertion-related dependencies is a major cause of false negatives in other tools. ASD allows the tool to see how a "revert" in one part of the code can be used to manipulate a state variable elsewhere.

Key Results

  • High Accuracy: On the manually labeled dataset, SmartState achieved a precision of 87.23% and a recall of 89.13%.
  • Ablation Success: Removing the ASD and TSD components caused the recall to plummet from ~89% to ~58%, proving that these novel dependency types are critical for detection.
  • Real-World Impact: When run against 47,351 contracts, SmartState identified 406 new SRVs. 11 of these were found in "popular" contracts (top 2000 by transaction volume), affecting digital assets worth approximately $428,600 USD.
  • Superiority over SOTA: SmartState significantly outperformed existing tools like eTainter, Madmax, and Slither, particularly in reducing false positives (achieving 84.16% precision vs. Slither's 7.08% on the large-scale test).

Limitations and Future Work

  • Dependency on Pre-processors: SmartState relies on an existing tool (SmartDagger) for initial control-flow recovery. If the pre-processor fails to identify function boundaries correctly, SmartState may produce false positives.
  • Oracle/Off-chain Data: As a static analysis tool, it cannot account for vulnerabilities that depend on data from external oracles or third-party platforms not controlled by the blockchain.
  • Expanding Scopes: While the tool currently focuses on profit-gain and DoS attacks, the authors suggest that the framework could be extended to detect other emerging types of state-related vulnerabilities.

Summary updated

BibTeX
@inproceedings{liao2023smartstate,
  author = {Zeqin Liao and Sicheng Hao and Yuhong Nan and Zibin Zheng},
  title = {{SmartState: Detecting State-Reverting Vulnerabilities in Smart Contracts via Fine-Grained State-Dependency Analysis}},
  booktitle = {ISSTA},
  year = {2023},
  doi = {10.1145/3597926.3598111},
}
Figure