SolidityCheck : Quickly Detecting Smart Contract Problems Through Regular Expressions

Pengcheng Zhang (张鹏程), Pengcheng Zhang, Feng Xiao, Xiapu LuoarXiv 2019

Abstract

SolidityCheck is a high-speed static analysis tool designed to identify 20 different types of vulnerabilities and performance issues in Ethereum smart contracts using regular expressions and program instrumentation. By shifting analysis from complex XML-based parsing to optimized regex matching with keyword filtering, it achieves a nearly 7x speedup over existing source-code analyzers while maintaining a superior 97% recall rate.

Introduction

Smart contracts on the Ethereum blockchain are immutable; once deployed, their code cannot be patched. This "code is law" philosophy means that a single bug—such as the re-entrancy vulnerability that led to the $50 million DAO hack—can result in permanent financial loss. While many tools exist to find these bugs, they often face a trade-off between speed and semantic context. Bytecode-based tools lose function-level context, while source-based tools like SmartCheck rely on computationally expensive XML parse trees.

SolidityCheck addresses these challenges by providing a tool that is fast enough for real-time development while remaining highly accurate at the source-code level. It categorizes smart contract issues into three primary domains: security problems, performance bottlenecks, and hidden coding threats.

Classification of smart contract problems addressed by SolidityCheck.

Methodology

SolidityCheck employs a four-step pipeline designed to balance analysis speed with detection depth.

  1. Code Formatting: To ensure regular expression (regex) reliability, the tool pre-processes the code by removing comments and blank lines and reformating multi-line statements into single lines.
  2. Keyword Filtering: To avoid performance pitfalls like NFA backtracking, the tool first scans for specific keywords (e.g., for, tx.origin). Expensive regex matching is only executed on lines containing these triggers.
  3. Regex-Based Detection: The core engine uses a library of 20 specialized regex patterns to identify security vulnerabilities (high severity), performance bottlenecks (medium), and style violations (low).
  4. Program Instrumentation: For complex bugs like re-entrancy and integer overflow, SolidityCheck automatically injects "vaccine" code—safety checks and state guards—into the contract to prevent exploits at runtime.
The four-step detection and prevention pipeline of SolidityCheck.

Experimental Evaluation

The authors evaluated SolidityCheck using a dataset of 1,363 smart contracts crawled from Etherscan.io, totaling 1,239,927 lines of code. The tool was benchmarked against eight prominent industry tools, including Remix, MythX, Oyente, Securify, and SmartCheck.

Key Results

  • Efficiency: SolidityCheck demonstrated a 683.4% improvement in efficiency over SmartCheck, processing the entire dataset in 318 seconds compared to SmartCheck's nearly 2,500 seconds.
  • Accuracy: The tool achieved an overall recall of 97.0%, significantly outperforming SmartCheck’s 50.9%.
  • Real-world Impact: Testing revealed two previously unreported re-entrancy vulnerabilities and 10 contracts with "locked money" issues that other tools had missed.
  • Prevention: The instrumentation successfully blocked integer overflows in the BEC token contract, a vulnerability that historically caused a total collapse of the token's market value.

Discussion and Future Work

The research demonstrates that a full Abstract Syntax Tree (AST) is not always necessary for effective bug detection. When code is correctly formatted, regex-based analysis combined with keyword filtering provides a viable, high-speed alternative for large-scale automated scanning. Furthermore, the "vaccine" approach offers a proactive layer of security for complex logic errors.

Future work will focus on improving the user experience by integrating the tool directly into IDEs and maintaining regex patterns to keep pace with the evolving Solidity language. Additionally, the authors aim to enhance the tool's ability to track logic across broader scopes, such as vulnerabilities spanning multiple functions or files.

Summary updated

BibTeX
@misc{2019soliditycheck,
  author = {Pengcheng Zhang (张鹏程) and Pengcheng Zhang and Feng Xiao and Xiapu Luo},
  title = {{SolidityCheck : Quickly Detecting Smart Contract Problems Through Regular Expressions}},
  year = {2019},
  eprint = {1911.09425},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1911.09425},
}
Figure