EOSFuzzer: Fuzzing EOSIO Smart Contracts for Vulnerability Detection

Bo Jiang, Professor, Yuhe Huang, Bo Jiang, Wing Kwong ChanInternetware 2020 · DOI

TL;DR

This paper introduces EOSFuzzer, a novel black-box fuzzing framework designed to automatically detect vulnerabilities in EOSIO smart contracts. By developing specialized attacking scenarios and test oracles, EOSFuzzer effectively identifies common security flaws, demonstrating significant accuracy and efficiency in its experimental evaluation.

What Problem Does This Paper Address?

The EOSIO blockchain platform, known for its scalability and growing ecosystem of decentralized applications (DApps), is unfortunately susceptible to security vulnerabilities within its smart contracts. These vulnerabilities have led to substantial financial losses for users, with examples including the loss of thousands of EOS tokens due to issues like random number generation flaws and fake transfer notifications. While fuzzing is a common technique for finding bugs in software, there was a lack of specialized tools for EOSIO smart contracts. The unique EOSIO token transfer mechanism and its execution within a WebAssembly (WASM) virtual machine present distinct challenges compared to other platforms like Ethereum, necessitating tailored approaches for effective vulnerability detection.

Methods

EOSFuzzer employs a general black-box fuzzing approach, meaning it doesn't require access to the smart contract's source code. Its core components include:

  • Fuzzing Input Generator: This component analyzes the Application Binary Interface (ABI) of smart contracts to generate diverse inputs. Crucially, it also creates specific "attacking scenarios" using helper "attacker agent contracts" designed to trigger known vulnerabilities.
  • Fuzzing Executor: This component efficiently executes the generated inputs against the target smart contract within a testnet environment.
  • Instrumented WASM VM: The WASM virtual machine, which executes EOSIO smart contracts, is instrumented to collect detailed execution information, such as opcode execution and API calls. This instrumentation is designed to be general enough to support the detection of various vulnerabilities.
  • Vulnerability Detection Engine: This engine implements custom test oracles that analyze the execution logs from the instrumented VM to identify specific vulnerabilities. The paper details oracles for three common EOSIO smart contract vulnerabilities: Fake EOS Transfer, Forged Transfer Notification, and Block Information Dependency.

The framework also incorporates static analysis of the ABI and bytecode to inform input generation and a candidate string pool for memo parameters.

Datasets

The paper evaluates EOSFuzzer on two sets of EOSIO smart contracts:

  • 82 open-source EOSIO smart contracts: These were used for manual verification of the tool's effectiveness.
  • 3881 EOSIO smart contracts without source code: These contracts, provided only with Wasm bytecode and ABI files, were used to evaluate EOSFuzzer at scale.

The authors did not introduce a new benchmark dataset but rather used existing EOSIO smart contracts available in the ecosystem.

Key Insights and Ideas

  • Tailored Attack Scenarios are Crucial: Simply generating random inputs isn't enough. EOSFuzzer's success hinges on its ability to craft specific "attacker agent contracts" that mimic real-world attack patterns for EOSIO.
  • WASM Instrumentation is Key for Visibility: The ability to instrument the WASM VM and capture detailed execution traces (opcodes, API calls) is fundamental for building effective test oracles that can distinguish between normal execution and exploitable behavior.
  • EOSIO's Unique Transfer Mechanism Requires Special Oracles: The eosio.token system contract and the require_recipient mechanism introduce specific attack vectors that necessitate custom-designed test oracles, rather than generic ones.
  • Black-Box Fuzzing is Viable for EOSIO: The paper demonstrates that effective vulnerability detection can be achieved even without source code, making it applicable to a wider range of smart contracts.
  • False Positives are Manageable but Require Careful Oracle Design: While fuzzing can generate false positives, the paper shows that by carefully designing test oracles and considering the nuances of EOSIO's execution environment, these can be minimized.

Key Results

EOSFuzzer demonstrated strong performance in its experimental evaluation:

  • Effectiveness: The framework successfully detected vulnerabilities in real-world EOSIO smart contracts.
  • Accuracy: On 82 open-source contracts, EOSFuzzer reported:
  • 2/2 Block Information Dependency vulnerabilities (1 false negative).
  • 4/4 Forged Transfer Notification vulnerabilities (0 false positives/negatives).
  • 2/2 Fake EOS Transfer vulnerabilities (1 false positive).
  • Scalability: When tested on 3881 contracts without source code, EOSFuzzer identified a significant number of potential vulnerabilities: 3 for Block Information Dependency (0.07%), 183 for Forged Transfer Notification (4.72%), and 265 for Fake EOS Transfer (6.83%).
  • Efficiency: The fuzzing process for each contract averaged around 90 seconds, with approximately 11 invocations per second, making it efficient for comprehensive testing.
  • Real-World Attack Simulation: The paper highlights a successful attack scenario where EOSFuzzer was used to make a bet and earn rewards without spending any EOS on a contract without source code.
  • Comparison with EVulHunter: EOSFuzzer outperformed EVulHunter in detecting Forged Transfer Notification vulnerabilities (fewer false positives and missed vulnerabilities) and showed significantly lower false positives for Fake EOS Transfer.

Limitations and Future Work

  • False Negatives: The paper acknowledges a false negative for Block Information Dependency in the lottery10 contract, suggesting that a larger-scale fuzzing effort or feedback-driven fuzzing might be needed for such complex scenarios.
  • False Positives: A false positive was identified for Fake EOS Transfer in the vigor contract due to its non-standard handling of EOS transfers. The authors note that contracts using functions other than transfer for EOS handling are unusual but can lead to false positives if not accounted for.
  • Stateless Fuzzing: Currently, EOSFuzzer performs stateless fuzzing. The authors propose extending it to stateful fuzzing by incorporating code coverage information and data-flow analysis to guide the fuzzing process more effectively.
  • New Vulnerability Types: Future work includes extending EOSFuzzer to detect new types of vulnerabilities, such as the rollback vulnerability in gambling DApps, by developing new attacker agents and test oracles.
  • Inter-contract Dependencies: The current analysis of name and public_key parameters is limited. Future work could involve analyzing relationships among smart contracts within a project for more comprehensive security analysis.

Summary updated

BibTeX
@inproceedings{professor2020eosfuzzer,
  author = {Bo Jiang, Professor and Yuhe Huang and Bo Jiang and Wing Kwong Chan},
  title = {{EOSFuzzer: Fuzzing EOSIO Smart Contracts for Vulnerability Detection}},
  booktitle = {Internetware},
  year = {2020},
  doi = {10.1145/3457913.3457920},
}
Figure