Smart contracts need user conditions to resist frontrunning attacks
On Identifying Sound Conditions for Frontrunning Resistance
Cryptography and Security
Summary
Blockchain programs called smart contracts can be cheated by miners who reorder or insert transactions to benefit themselves, known as frontrunning. The authors found that current ways to detect these vulnerabilities miss over half of real cases. They introduced a new way to define when a contract is safe from frontrunning that depends on how honest users interact with it, not just the contract itself. They created a method to find the right conditions users must follow to keep contracts secure and found new vulnerabilities in existing Ethereum contracts.
What this means in practice
- •For blockchain developers: Identify secure ways for users to interact with smart contracts to prevent frontrunning exploits in deployed systems.
- •For blockchain security auditors: Use a formal definition and algorithm to detect previously unknown frontrunning vulnerabilities during contract audits.
Authors
Sebastian Holler, Anna Piscitelli, Jannik Albrecht, Stephan Dübler, Ghassan Karame, Clara Schneidewind
Abstract
Blockchains enable decentralized applications through smart contracts---interactive programs executed through consensus. However, the inherently asynchronous nature of blockchain transaction ordering introduces a class of vulnerabilities known as frontrunning attacks, which have caused millions of dollars in losses in major blockchains, such as Ethereum. Frontrunning attacks arise because users interact with smart contracts through transactions, which are added to the blockchain by designated nodes called miners. Miners can exploit their ability to reorder, delay, or insert transactions to gain an advantage over honest users, effectively frontrunning them. Yet, to date, the field lacks a rigorous definition of what it even means for a contract to resist such attacks. Worse, we show that existing dynamic detection approaches are fundamentally inadequate: in a large-scale study comprising 287 smart contract audits, 55% of the 393 reported vulnerabilities identified by leading smart contract auditors fall outside the scope of state-of-the-art detection criteria. To address this gap, we propose the first formal definition of frontrunning vulnerability for smart contracts. Our definition captures a key insight: resistance to frontrunning is not an intrinsic property of a contract alone, but depends critically on how honest users interact with it. Grounded in this observation, we develop a sound algorithm for synthesizing secure interaction conditions, alongside a prototype implementation that we apply to audited real-world contracts---revealing previously undiscovered vulnerabilities in two Ethereum contracts.