V-Gas: Generating High Gas Consumption Inputs to Avoid Out-of-Gas Vulnerability

Abstract

Out-of-gas errors occur when smart contract programs are provided with inputs that cause excessive gas consumption and which will be easily exploited to perform DoS attacks. Various approaches have been proposed to estimate the gas limit of a function in smart contracts to avoid such error. However, underestimation often occurs when the contract is complex In this work, we propose V-Gas, which automatically generates inputs that maximize the gas cost and reduce underestimation. V-Gas is designed based on static analysis and feedback-directed mutational fuzz testing. First, V-Gas builds the gas weighted control flow graph (WCFG) of functions in smart contracts. Then, V-Gas develops gas consumption guided selection and mutation strategies to generate the input that maximize the gas consumption. For evaluation, we implement V-Gas based on js-evm, a widely used ethereum virtual machine written in Javascript, and conduct experiments on 736 real-world transactions recorded on Ethereum. 44.02% of the transactions would have out-of-gas errors based on the estimation results given by solc, means that the recorded real gas consumption for those transactions is larger than the gas limit estimated by solc. In comparison V-Gas could reduce the under estimation ratio to 13.86%. In order to evaluate the performance of feedback-directed engine in V-Gas, we implemented other directed fuzzing engines and compare their performance with V-Gas’s. The results showed that V-Gas generates the same or higher gas estimation value on 97.8% of the transactions with less time, usually within 5 minutes. Furthermore, V-Gas has exposed 25 previously unknown out-of-gas vulnerabilities in widely-used smart contracts, 6 of which have been assigned unique CVE identifiers in the US National Vulnerability Database.

Publication
ACM Transactions on Internet Technology

Citeable as:

Fuchen Ma, Meng Ren, Fu Ying, Wanting Sun, Houbing Song, Heyuan Shi, Yu Jiang, and Huizhong Li. 2022. V-Gas: Generating High Gas Consumption Inputs to Avoid Out-of-Gas Vulnerability. ACM Trans. Internet Technol. Just Accepted (January 2022). https://doi.org/10.1145/3511900