Enhancing Smart Contract Security Analysis with Execution Property Graphs

Kaihua Qin, Zhe Ye, Zhun Wang, Weilin Li, Liyi Zhou, Chao Zhang, Dawn Song, Arthur Gervais

TL;DR

This paper introduces CLUE, a novel dynamic analysis framework for Ethereum smart contracts that uses an "Execution Property Graph" (EPG) to represent contract execution. CLUE effectively detects complex vulnerabilities like reentrancy and price manipulation with high accuracy and efficiency, outperforming existing tools.

What Problem Does This Paper Address?

Smart contracts, while powerful, are prone to vulnerabilities that have led to billions of dollars in losses. Traditional security methods like audits and static analysis often miss complex runtime behaviors and inter-contract interactions. Existing dynamic analysis tools are often specialized for specific attacks, lacking generality. There's a pressing need for a unified, efficient, and generic representation of smart contract executions that can capture intricate details for both forensic analysis and real-time intrusion detection.

Methods

CLUE introduces the Execution Property Graph (EPG), a novel, unified graph representation that merges three fundamental views of smart contract execution:

  • Call Trace Graph (CTG): Captures the sequence and hierarchy of contract invocations, including asset flows.
  • Dynamic Control-Flow Graph (DCFG): Represents the actual execution paths within a contract, ignoring unvisited basic blocks.
  • Dynamic Dependence Graph (DDG): Models data and control dependencies, including storage updates.

CLUE then employs graph traversal techniques on the EPG to identify malicious patterns. For reentrancy, it uses three rules (REENTRANT, CONTROLBLOCK, SUCCBLOCK) to detect reentrant calls, outdated storage values, and out-of-order updates. For price manipulation, it uses a "WriteControl" traversal to identify unauthenticated storage changes that influence asset transfers.

Datasets

The evaluation uses a dataset derived from a reference dataset of attack transactions on Ethereum, specifically focusing on reentrancy and price manipulation. They also created three sub-datasets:

  • Attack: Transactions confirmed as attacks.
  • High-Gas: Transactions with high gas consumption, representing complex logic that might be misclassified.
  • Regular: Typical non-attack transactions.

For comparison with SOTA tools, they used a large dataset of Ethereum transactions and a specific price manipulation dataset (D1 from DEFORT).

Key Insights and Ideas

  • Unified Representation is Key: The EPG's strength lies in its ability to integrate call traces, control flow, and data dependencies. This holistic view is crucial for understanding complex attack mechanics that span multiple aspects of execution.
  • Graph Traversal for Security: Leveraging graph traversal on the EPG provides a powerful and generic way to identify attack patterns without needing source code. This makes the approach more robust and adaptable.
  • Adaptability for New Threats: The EPG's extensibility allows for easy integration of new domain knowledge or refinement of traversal rules to detect emerging attack variants, as demonstrated with read-only reentrancy.
  • Efficiency Matters for Real-time: CLUE's traversal approach is remarkably efficient, making it suitable for real-time intrusion detection, a critical capability for proactive security.

Key Results

  • High Accuracy: CLUE achieved a 100% True Positive Rate (TPR) for reentrancy attacks and 96.23% for price manipulation attacks in their dedicated attack datasets. False Positive Rates (FPR) were low (e.g., 0.87% for reentrancy, 1.49% for price manipulation on non-attack datasets).
  • Efficiency: The average transaction analysis time was 169ms, with many non-attack transactions processed in under 20ms, highlighting its potential for real-time use.
  • Novelty Detection: CLUE successfully identified 11 previously undiscovered reentrancy transactions and detected the read-only reentrancy attack, which eluded SOTA tools.
  • Comparison to SOTA: CLUE demonstrated comparable or superior accuracy to existing tools like SEREUM and TXSPECTOR for reentrancy, and outperformed SOTA price manipulation tools in TPR. It also showed significantly better efficiency.
  • Ablation Study: Removing any component of the EPG (CTG, DCFG, or DDG) either degraded accuracy, increased detection time, or made the traversals non-executable, underscoring the necessity of the unified EPG structure.

Limitations and Future Work

  • Single Transaction Focus: CLUE currently lacks the capability to detect attacks spanning multiple transactions. Enhancing CLUE for multi-transaction attack detection is a key area for future work.
  • Domain-Specific Knowledge: While CLUE is generic, some attacks (like price manipulation) benefit from integrating domain-specific knowledge. The paper suggests this integration can further reduce FPR and False Negative Rates (FNR).
  • Machine Learning Potential: The rich features captured by the EPG could serve as valuable input for machine learning models to detect reentrancy attacks, which is identified as a future research direction.

Summary updated

BibTeX
@article{qin2023enhancing,
  author = {Kaihua Qin and Zhe Ye and Zhun Wang and Weilin Li and Liyi Zhou and Chao Zhang and Dawn Song and Arthur Gervais},
  title = {{Enhancing Smart Contract Security Analysis with Execution Property Graphs}},
  journal = {Proc. ACM Softw. Eng.},
  year = {2023},
  url = {https://openreview.net/forum?id=hWZ0hJsWj9},
}
Figure