Towards Effective Guidance of Smart Contract Fuzz Testing Based on Static Analysis
Abstract
:1. Introduction
- We propose an algorithm to generate a compact initial seed corpus for smart contract fuzzing while retaining meaningful function call orderings in the seeds.
- We propose a static taint analysis for smart contract bytecode that can precisely identify the data-flows between functions, even in the presence of variable packing optimization.
- We empirically show that our techniques can significantly improve the bug-finding capability of smart contract fuzzing. For open science, we make our implementation publicly available at https://doi.org/10.5281/zenodo.14738106.
2. Background
2.1. Ethereum Smart Contract
2.2. Smart Contract Security
3. Related Work
3.1. Smart Contract Analysis and Testing
3.2. Generation of Transaction Sequence
4. Guiding Smart Contract Fuzzing: Challenges
4.1. Redundancy of Test Cases
4.2. Imprecision of Static Analysis
5. Methodology
5.1. Algorithm for Compact Seed Generation
Algorithm 1: Initialization of function call sequences in fuzzing seeds. |
5.2. Taint Analysis to Handle Variable Packing
- Step 1.
- Construct the control-flow graph of the provided contract code.
- Step 2.
- Collect data-flow facts at each program point by applying the abstract semantics for taint analysis. The abstract semantics of each EVM instruction capture how the storage variables are accessed, extracted, and propagated in the program.
- Step 3.
- Examine the taint sink instructions to identify the data-flows propagated from the taint sources. At this step, we can observe which byte offsets of a storage variable are actually used in the program.
5.3. Implementation
6. Evaluation
- Q1.
- How do our techniques affect the size of the initial seed set generated for fuzzing?
- Q2.
- Can our techniques improve the bug-finding effectiveness of smart contract fuzzing?
- Q3.
- Does our system outperform other smart contract testing tools?
6.1. Experimental Setup
6.2. Impact on the Initial Seed Set
6.3. Impact on the Fuzzing Effectiveness
6.4. Comparison with Other Tools
7. Conclusions
Author Contributions
Funding
Data Availability Statement
Conflicts of Interest
References
- Finley, K. A $50 Million Hack Just Showed That the DAO Was All Too Human. Available online: https://www.wired.com/2016/06/50-million-hack-just-showed-dao-human/ (accessed on 11 February 2025).
- Town, S. BatchOverflow Exploit Creates Trillions of Ethereum Tokens, Major Exchanges Halt ERC20 Deposits. Available online: https://cryptoslate.com/batchoverflow-exploit-creates-trillions-of-ethereum-tokens/ (accessed on 11 February 2025).
- Miller, B.P.; Fredriksen, L.; So, B. An Empirical Study of the Reliability of UNIX Utilities. Commun. ACM 1990, 33, 32–44. [Google Scholar] [CrossRef]
- Manès, V.J.M.; Han, H.; Han, C.; Cha, S.K.; Egele, M.; Schwartz, E.J.; Woo, M. The Art, Science, and Engineering of Fuzzing: A Survey. IEEE Trans. Softw. Eng. 2021, 47, 2312–2331. [Google Scholar] [CrossRef]
- Fioraldi, A.; Maier, D.; Eißfeldt, H.; Heuse, M. AFL++: Combining incremental steps of fuzzing research. In Proceedings of the USENIX Workshop on Offensive Technologies, Online, 11 August 2020. [Google Scholar]
- Sutton, M.; Greene, A. The Art of File Format Fuzzing. In Proceedings of the Black Hat Asia, Tokyo, Japan, 17–18 October 2005. [Google Scholar]
- Corina, J.; Machiry, A.; Salls, C.; Shoshitaishvili, Y.; Hao, S.; Kruegel, C.; Vigna, G. DIFUZE: Interface Aware Fuzzing for Kernel Drivers. In Proceedings of the ACM Conference on Computer and Communications Security, Dallas, TX, USA, 30 October–3 November 2017; pp. 2123–2138. [Google Scholar]
- Ruiter, J.D.; Poll, E. Protocol State Fuzzing of TLS Implementations. In Proceedings of the USENIX Security Symposium, Washington, DC, USA, 12–14 August 2015; pp. 193–206. [Google Scholar]
- Jiang, B.; Liu, Y.; Chan, W.K. ContractFuzzer: Fuzzing Smart Contracts for Vulnerability Detection. In Proceedings of the International Conference on Automated Software Engineering, Montpellier, France, 3–7 September 2018; pp. 259–269. [Google Scholar]
- He, J.; Balunović, M.; Ambroladze, N.; Tsankov, P.; Vechev, M. Learning to Fuzz from Symbolic Execution with Application to Smart Contracts. In Proceedings of the ACM Conference on Computer and Communications Security, London, UK, 11–15 November 2019; pp. 531–548. [Google Scholar]
- Nguyen, T.D.; Pham, L.H.; Sun, J.; Lin, Y.; Minh, Q.T. sFuzz: An Efficient Adaptive Fuzzer for Solidity Smart Contracts. In Proceedings of the International Conference on Software Engineering, Seoul, Republic of Korea, 27 June–19 July 2020; pp. 778–788. [Google Scholar]
- Grieco, G.; Song, W.; Cygan, A.; Feist, J.; Groce, A. Echidna: Effective, Usable, and Fast Fuzzing for Smart Contracts. In Proceedings of the International Symposium on Software Testing and Analysis, Virtual, 18–22 July 2020; pp. 557–560. [Google Scholar]
- Wüstholz, V.; Christakis, M. Targeted Greybox Fuzzing with Static Lookahead Analysis. In Proceedings of the International Conference on Software Engineering, Seoul, Republic of Korea, 27 June–19 July 2020; pp. 789–800. [Google Scholar]
- Choi, J.; Kim, D.; Kim, S.; Grieco, G.; Groce, A.; Cha, S.K. SMARTIAN: Enhancing Smart Contract Fuzzing with Static and Dynamic Data-Flow Analyses. In Proceedings of the International Conference on Automated Software Engineering, Melbourne, Australia, 15–19 November 2021. [Google Scholar]
- Rival, X.; Yi, K. Introduction to Static Analysis: An Abstract Interpretation Perspective; MIT Press: Cambridge, MA, USA, 2020. [Google Scholar]
- Møller, A.; Schwartzbach, M.I. Static Program Analysis. Available online: https://cs.au.dk/~amoeller/spa/ (accessed on 11 February 2025).
- Layout of State Variables in Storage and Transient Storage. Available online: https://docs.soliditylang.org/en/latest/internals/layout_in_storage.html (accessed on 11 February 2025).
- Arzt, S.; Rasthofer, S.; Fritz, C.; Bodden, E.; Bartel, A.; Klein, J.; Le Traon, Y.; Octeau, D.; McDaniel, P. FlowDroid: Precise context, flow, field, object-sensitive and lifecycle-aware taint analysis for android apps. ACM Sigplan Not. 2014, 49, 259–269. [Google Scholar] [CrossRef]
- Wang, T.; Wei, T.; Gu, G.; Zou, W. TaintScope: A Checksum-Aware Directed Fuzzing Tool for Automatic Software Vulnerability Detection. In Proceedings of the IEEE Symposium on Security and Privacy, Oakland, CA, USA, 16–19 May 2010; pp. 497–512. [Google Scholar]
- Nikoliundefined, I.; Kolluri, A.; Sergey, I.; Saxena, P.; Hobor, A. Finding The Greedy, Prodigal, and Suicidal Contracts at Scale. In Proceedings of the Annual Computer Security Applications Conference, San Jua, PR, USA, 3–7 December 2018; pp. 653–663. [Google Scholar]
- Li, K.; Xue, Y.; Chen, S.; Liu, H.; Sun, K.; Hu, M.; Wang, H.; Liu, Y.; Chen, Y. Static Application Security Testing (SAST) Tools for Smart Contracts: How Far Are We? In Proceedings of the ACM on Software Engineering, Kyoto, Japan, 13–15 September 2024; pp. 1447–1470. [Google Scholar]
- OpenZeppelin Group. SafeMath. Available online: https://docs.openzeppelin.com/contracts/2.x/api/math (accessed on 11 February 2025).
- Tikhomirov, S.; Voskresenskaya, E.; Ivanitskiy, I.; Takhaviev, R.; Marchenko, E.; Alexandrov, Y. SmartCheck: Static Analysis of Ethererum Smart Contracts. In Proceedings of the 1st International Workshop on Emerging Trends in Software Engineering for Blockchain, Gothenburg, Sweden, 27 May–3 June 2018; pp. 9–16. [Google Scholar]
- Tsankov, P.; Dan, A.; Drachsler-Cohen, D.; Gervais, A.; Bünzli, F.; Vechev, M. Securify: Practical Security Analysis of Smart Contracts. In Proceedings of the ACM Conference on Computer and Communications Security, Toronto, ON, Canada, 15–19 October 2018; pp. 67–82. [Google Scholar]
- Ullman, J.D. Principles of Database and Knowledge-Base Systems; Computer Science Press: New York, NY, USA, 1988; Volume 1. [Google Scholar]
- Feist, J.; Grieco, G.; Groce, A. Slither: A Static Analysis Framework For Smart Contracts. In Proceedings of the 2nd International Workshop on Emerging Trends in Software Engineering for Blockchain, Montreal, QC, Canada, 27 May 2019; pp. 8–15. [Google Scholar]
- So, S.; Lee, M.; Park, J.; Lee, H.; Oh, H. VeriSmart: A Highly Precise Safety Verifier for Ethereum Smart Contracts. In Proceedings of the IEEE Symposium on Security and Privacy, San Francisco, CA, USA, 18–21 May 2020; pp. 1678–1694. [Google Scholar]
- Mueller, B. Smashing Ethereum Smart Contracts for Fun and Actual Profit. In Proceedings of the HITB Security Conference, Dubai, United Arab Emirates, 27–28 November 2018. [Google Scholar]
- Sen, K.; Marinov, D.; Agha, G. CUTE: A Concolic Unit Testing Engine for C. In Proceedings of the International Symposium on the Foundations of Software Engineering, Lisbon, Portugal, 5–9 September 2005; pp. 263–272. [Google Scholar]
- Godefroid, P.; Klarlund, N.; Sen, K. DART: Directed Automated Random Testing. In Proceedings of the ACM Conference on Programming Language Design and Implementation, Chicago, IL, USA, 12–15 June 2005; pp. 213–223. [Google Scholar]
- Godefroid, P.; Levin, M.Y.; Molnar, D.A. Automated Whitebox Fuzz Testing. In Proceedings of the Network and Distributed System Security Symposium, San Diego, CA, USA, 10–13 February 2008; pp. 151–166. [Google Scholar]
- Böhme, M.; Pham, V.T.; Nguyen, M.D.; Roychoudhury, A. Directed Greybox Fuzzing. In Proceedings of the ACM Conference on Computer and Communications Security, Dallas, TX, USA, 30 October–3 November 2017; pp. 2329–2344. [Google Scholar]
- Luo, C.; Meng, W.; Li, P. SELECTFUZZ: Efficient Directed Fuzzing with Selective Path Exploration. In Proceedings of the IEEE Symposium on Security and Privacy, San Francisco, CA, USA, 21–25 May 2023; pp. 1050–1064. [Google Scholar]
- Liang, R.; Chen, J.; Wu, C.; He, K.; Wu, Y.; Cao, R.; Du, R.; Zhao, Z.; Liu, Y. Vulseye: Detect smart contract vulnerabilities via stateful directed graybox fuzzing. IEEE Trans. Inf. Forensics Secur. 2025. [Google Scholar] [CrossRef]
- Shou, C.; Tan, S.; Sen, K. ItyFuzz: Snapshot-based fuzzer for smart contract. In Proceedings of the International Symposium on Software Testing and Analysis, Seattle, WA, USA, 17–21 July 2023; pp. 322–333. [Google Scholar]
- Schumilo, S.; Aschermann, C.; Abbasi, A.; Wörner, S.; Holz, T. Nyx: Greybox hypervisor fuzzing using fast snapshots and affine types. In Proceedings of the USENIX Security Symposium, Virtual, 11–13 August 2021; pp. 2597–2614. [Google Scholar]
- Wang, Z.; Chen, J.; Wang, Y.; Zhang, Y.; Zhang, W.; Zheng, Z. Efficiently detecting reentrancy vulnerabilities in complex smart contracts. In Proceedings of the International Symposium on the Foundations of Software Engineering, Porto de Galinhas, Brazil, 15–19 July 2024; pp. 161–181. [Google Scholar]
- Gritti, F.; Ruaro, N.; McLaughlin, R.; Bose, P.; Das, D.; Grishchenko, I.; Kruegel, C.; Vigna, G. Confusum contractum: Confused deputy vulnerabilities in ethereum smart contracts. In Proceedings of the USENIX Security Symposium, Anaheim, CA, USA, 9–11 August 2023; pp. 1793–1810. [Google Scholar]
- Qian, P.; Wu, H.; Du, Z.; Vural, T.; Rong, D.; Cao, Z.; Zhang, L.; Wang, Y.; Chen, J.; He, Q. MuFuzz: Sequence-aware mutation and seed mask guidance for blockchain smart contract fuzzing. In Proceedings of the IEEE International Conference on Data Engineering, Utrecht, The Netherlands, 13–16 May 2024; pp. 1972–1985. [Google Scholar]
- Wüstholz, V.; Christakis, M. Harvey: A Greybox Fuzzer for Smart Contracts. In Proceedings of the International Symposium on the Foundations of Software Engineering: Industry Papers, Virtual, 8–13 November 2020; pp. 1398–1409. [Google Scholar]
- Su, J.; Dai, H.N.; Zhao, L.; Zibin Zheng, X.L. Effectively Generating Vulnerable Transaction Sequences in Smart Contracts with Reinforcement Learning-guided Fuzzing. In Proceedings of the International Conference on Automated Software Engineering, Rochester, MI, USA, 10–14 October 2022; pp. 1–12. [Google Scholar]
- So, S.; Hong, S.; Oh, H. SmarTest: Effectively Hunting Vulnerable Transaction Sequences in Smart Contracts through Language Model-Guided Symbolic Execution. In Proceedings of the USENIX Security Symposium, Virtual, 11–13 August 2021. [Google Scholar]
- Aho, A.V.; Lam, M.S.; Sethi, R.; Ullman, J.D. Compilers: Principles, Techniques, and Tools, 2nd ed.; Addison Wesley: Boston, MA, USA, 2006. [Google Scholar]
- SoftSec Lab. Smartian GitHub Repository. Available online: https://github.com/SoftSec-KAIST/Smartian (accessed on 11 February 2025).
- Durieux, T.; Ferreira, J.F.; Abreu, R.; Cruz, P. Empirical Review of Automated Analysis Tools on 47,587 Ethereum Smart Contracts. In Proceedings of the International Conference on Software Engineering, Seoul, Republic of Korea, 27 June–19 July 2020; pp. 530–541. [Google Scholar]
- Chen, H.; Xue, Y.; Li, Y.; Chen, B.; Xie, X.; Wu, X.; Liu, Y. Hawkeye: Towards a Desired Directed Grey-box Fuzzer. In Proceedings of the ACM Conference on Computer and Communications Security, Toronto, ON, Canada, 15–19 October 2018; pp. 2095–2108. [Google Scholar]
Modes for Seed Generation | Num. of Generated Seeds | Average Length of Seeds | ||||
---|---|---|---|---|---|---|
Min | Max | Avg | Min | Max | Avg * | |
Baseline (original Smartian) | 9 | 234 | 48.3 | 2.8 | 7.6 | 4.2 |
Ours (with SeedGen algorithm only) | 1 | 9 | 3.5 | 4.5 | 64.0 | 15.3 |
Ours (with both SeedGen algorithm and taint analysis) | 1 | 11 | 3.7 | 3.5 | 58.0 | 11.5 |
CVE | Baseline (Smartian) | Ours (SeedGen Only) | Ours (SeedGen + Taint Analysis) | ||
---|---|---|---|---|---|
TTE | TTE | Rate | TTE | Rate | |
2018-10299 | 6 | 5 | 83% | 3 | 50% |
2018-10376 | 261 | 413 | 158% | 158 | 61% |
2018-10468 | 217 | 98 | 45% | 91 | 42% |
2018-10706 | 20 | 42 | 210% | 34 | 170% |
2018-11239 | 12 | 24 | 200% | 17 | 142% |
2018-11411 | 22 | 19 | 86% | 17 | 77% |
2018-11429 | 50 | 37 | 74% | 25 | 50% |
2018-11446 | 1088 | 270 | 25% | 292 | 27% |
2018-11561 | 2 | 2 | 100% | 2 | 100% |
2018-11687 | 43 | 76 | 179% | 50 | 118% |
2018-12070 | 75 | 33 | 44% | 34 | 45% |
2018-12230 | 11 | 10 | 91% | 8 | 73% |
2018-13126 | 109 | 25 | 23% | 32 | 29% |
2018-13127 | 332 | 59 | 18% | 56 | 17% |
2018-13128 | 240 | 28 | 12% | 29 | 12% |
2018-13129 | 728 | 61 | 8% | 63 | 9% |
2018-13131 | 448 | 64 | 14% | 60 | 13% |
2018-13132 | 724 | 66 | 9% | 60 | 8% |
2018-13189 | 52 | 10 | 19% | 11 | 21% |
2018-13202 | 29 | 27 | 95% | 26 | 91% |
2018-13208 | 81 | 51 | 63% | 61 | 75% |
2018-13220 | 33 | 23 | 71% | 22 | 68% |
2018-13221 | 22 | 30 | 136% | 29 | 132% |
2018-13225 | 35 | 26 | 75% | 22 | 64% |
2018-13227 | 88 | 52 | 59% | 47 | 54% |
2018-13228 | 84 | 70 | 84% | 53 | 63% |
2018-13230 | 57 | 44 | 78% | 35 | 62% |
2018-13327 | 586 | 390 | 67% | 447 | 76% |
2018-13493 | 29 | 17 | 59% | 15 | 52% |
2018-13533 | 5 | 10 | 200% | 8 | 160% |
2018-13625 | 48 | 32 | 67% | 24 | 50% |
2018-13670 | 24 | 7 | 30% | 6 | 26% |
2018-13698 | 4 | 2 | 50% | 2 | 50% |
2018-13703 | 9 | 6 | 71% | 6 | 71% |
2018-13777 | 27 | 9 | 33% | 7 | 26% |
2018-13778 | 23 | 8 | 35% | 7 | 30% |
2018-13779 | 41 | 14 | 34% | 12 | 29% |
2018-13782 | 42 | 15 | 36% | 9 | 21% |
2018-13783 | 152 | 33 | 22% | 30 | 20% |
2018-13836 | 25 | 29 | 116% | 27 | 108% |
2018-14001 | 9 | 10 | 111% | 11 | 122% |
2018-14002 | 19 | 19 | 100% | 17 | 89% |
2018-14003 | 6 | 3 | 55% | 3 | 55% |
2018-14004 | 31 | 32 | 105% | 27 | 89% |
2018-14005 | 20 | 16 | 82% | 12 | 62% |
2018-14006 | 25 | 32 | 128% | 29 | 116% |
2018-14063 | 32 | 29 | 91% | 27 | 84% |
2018-14084 | 93 | 42 | 45% | 40 | 43% |
2018-14086 | 15 | 14 | 93% | 12 | 80% |
2018-14087 | 455 | 34 | 7% | 34 | 7% |
2018-14089 | 76 | 55 | 72% | 43 | 57% |
2018-14576 | 37 | 24 | 66% | 34 | 93% |
2018-17050 | 24 | 24 | 100% | 20 | 83% |
2018-18665 | 8 | 4 | 50% | 3 | 38% |
Total | 6725 | 2563 | 38% | 2240 | 33% |
Tools | Ours | SmarTest | sFuzz | Mythril |
---|---|---|---|---|
# of found bugs | 54 | 50 | 13 | 8 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Park, J.; Choi, J. Towards Effective Guidance of Smart Contract Fuzz Testing Based on Static Analysis. Electronics 2025, 14, 806. https://doi.org/10.3390/electronics14040806
Park J, Choi J. Towards Effective Guidance of Smart Contract Fuzz Testing Based on Static Analysis. Electronics. 2025; 14(4):806. https://doi.org/10.3390/electronics14040806
Chicago/Turabian StylePark, Jeongwon, and Jaeseung Choi. 2025. "Towards Effective Guidance of Smart Contract Fuzz Testing Based on Static Analysis" Electronics 14, no. 4: 806. https://doi.org/10.3390/electronics14040806
APA StylePark, J., & Choi, J. (2025). Towards Effective Guidance of Smart Contract Fuzz Testing Based on Static Analysis. Electronics, 14(4), 806. https://doi.org/10.3390/electronics14040806