Skip to main content
QUICK REVIEW

[Paper Review] Running on Fumes--Preventing Out-of-Gas Vulnerabilities in Ethereum Smart Contracts using Static Resource Analysis

Elvira Albert, Pablo Gordillo|arXiv (Cornell University)|Nov 22, 2018
Security and Verification in ComputingComputer Science7 references8 citations
TL;DR

This paper presents Gastap, a static analysis platform that automatically infers precise upper bounds on gas consumption for Ethereum smart contract functions by analyzing Solidity or EVM bytecode. Using control-flow analysis, decompilation, size relation inference, and equation solving, Gastap provides sound, scalable, and accurate gas bounds that prevent out-of-gas vulnerabilities, with 68.36% of analysis time spent solving gas equations and 100% of 29,061 contracts analyzed in under 343 hours.

ABSTRACT

Gas is a measurement unit of the computational effort that it will take to execute every single operation that takes part in the Ethereum blockchain platform. Each instruction executed by the Ethereum Virtual Machine (EVM) has an associated gas consumption specified by Ethereum. If a transaction exceeds the amount of gas allotted by the user (known as gas limit), an out-of-gas exception is raised. There is a wide family of contract vulnerabilities due to out-of-gas behaviours. We report on the design and implementation of GASTAP, a Gas-Aware Smart contracT Analysis Platform, which takes as input a smart contract (either in EVM, disassembled EVM, or in Solidity source code) and automatically infers sound gas upper bounds for all its public functions. Our bounds ensure that if the gas limit paid by the user is higher than our inferred gas bounds, the contract is free of out-of-gas vulnerabilities.

Motivation & Objective

  • To address the lack of sound, automated tools for analyzing gas consumption in Ethereum smart contracts, especially for complex dependencies on input size and state.
  • To enable precise static estimation of worst-case gas usage, ensuring contracts are free from out-of-gas exceptions when gas limits exceed inferred bounds.
  • To overcome limitations of existing tools that provide only constant bounds or return ∞ by modeling dynamic gas dependencies on input parameters, contract state, and blockchain data.
  • To develop a scalable, end-to-end system that supports both high-level Solidity and low-level EVM bytecode inputs with formal soundness guarantees.
  • To demonstrate the feasibility and effectiveness of static resource analysis for Ethereum smart contracts at scale using real-world contracts.

Proposed method

  • Constructs control-flow graphs (CFGs) from EVM or Solidity code using an extended version of Oyente.
  • Performs decompilation to a higher-level intermediate representation (EthIR) to improve analysis precision.
  • Infers size relations between input parameters, contract state, and blockchain data using an adapted size analyzer from Saco.
  • Generates symbolic gas equations that model the dependency of gas consumption on input sizes and state variables.
  • Solves the resulting system of equations using the Pubs solver to derive closed-form upper bounds on gas usage.
  • Applies optimizations such as loop extraction and handles mutual recursion via cover point error detection, though this remains a limitation.

Experimental results

Research questions

  • RQ1Can a static analysis tool accurately infer worst-case gas bounds for Ethereum smart contract functions that depend on input size, state size, and blockchain data?
  • RQ2How effective is a static resource analysis approach in detecting out-of-gas vulnerabilities compared to pattern-based or symbolic execution methods?
  • RQ3What is the scalability and performance overhead of analyzing large-scale real-world smart contracts using static gas analysis?
  • RQ4To what extent do existing compilers and tools fail to provide precise gas bounds due to ad-hoc compilation strategies?
  • RQ5Can a formal, sound, and complete static analysis system be built for EVM gas consumption that supports both EVM bytecode and high-level Solidity code?

Key findings

  • Gastap successfully analyzed 29,061 real-world Ethereum smart contracts, with a total analysis time of 1,233,155.92 seconds (approximately 342.54 hours).
  • The most time-consuming phase was solving gas equations (68.36% of total time), indicating that equation solving is the performance bottleneck.
  • Equation generation accounted for 21.68% of total time, with opcode and memory gas bounds being generated separately.
  • The tool identified that nearly 10% of analyzed functions have gas consumption dependent on input size or contract state, highlighting a widespread but under-addressed vulnerability surface.
  • The system is sound: if a user provides a gas limit higher than Gastap’s inferred upper bound, the contract is guaranteed to not throw an out-of-gas exception.
  • The tool’s implementation leverages and extends existing open-source tools (Oyente, EthIR, Saco, Pubs), demonstrating feasibility of integrating modular components for complex static analysis.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.