BACKRUNNER: Mitigating Smart Contract Attacks in the Real World

Chaofan Shou, Yuanyu Ke, Yupeng Yang, Qi Su, Or Dadosh, Assaf Eli, David Benchimol, Doudou Lu, Daniel Tong, Dex Chen, Zoey Tan, Jacob Chia, Koushik Sen, Wenke LeearXiv 2024 · DOI

Abstract

Smart contract exploits continue to plague the decentralized finance (DeFi) ecosystem. Traditional "whitehat" defenses, primarily relying on attack frontrunning in public mempools, are increasingly bypassed by attackers using private transactions and aggressive gas bidding. This paper introduces BACKRUNNER, a novel defense framework that shifts the focus from reactive frontrunning to proactive "preemptive hijacking" and "attack backrunning." By analyzing exploit contracts upon deployment and repurposing them for rescue operations, BACKRUNNER identifies a critical lead-time window between contract deployment and attack execution. In real-world deployments, BACKRUNNER successfully mitigated 28 attacks, rescuing over $11.2 million, demonstrating its efficacy against modern, sophisticated exploit strategies.

Introduction

For years, the primary defense against smart contract exploits has been attack frontrunning. When a bot detects a malicious transaction in the public mempool, it attempts to copy the exploit and submit it with a higher gas fee to secure funds for victims before the attacker. However, this strategy is failing. Over 90% of blocks are now built by third parties (e.g., Flashbots) that allow hackers to send transactions privately, making them invisible until they are mined. Furthermore, even when attacks are public, intense bidding wars often result in up to 80% of rescued funds being paid to block builders as gas fees.

Methodology

BACKRUNNER moves the goalposts by analyzing the attack lifecycle differently. Most attacks involve two distinct steps: deploying an exploit contract and then triggering it.

The BACKRUNNER defense strategy targets different stages of the attack lifecycle compared to traditional frontrunning.

The framework utilizes a four-stage pipeline:

  1. Exploit Cloning: BACKRUNNER monitors the blockchain for the deployment of new contracts rather than waiting for trigger transactions. It uses dynamic analysis to explore execution paths within these new contracts.
  2. Rule-based Rewrite: The system treats attacker code as a "program repair" problem, identifying "holes" (e.g., missing constants like flashloan amounts) and filling them using predefined rules to redirect payouts to a whitehat address.
  3. Hybrid Fuzzing: For complex logic, it employs coverage-guided fuzzing and concolic execution to find profitable execution paths for the defender.
  4. Strategic Execution:
    • Preemptive Hijack: Executing the repaired exploit before the attacker triggers their contract.
  5. Attack Backrunning: If an initial attack succeeds, BACKRUNNER immediately adapts the exploit to target similar contracts or pools on other chains to rescue residual assets.

Key Insights: The Lead Time Advantage

A critical finding of this research is the existence of a significant window for intervention. Analysis of 54 major attacks revealed that the majority of exploit contracts were deployed well before the actual attack was triggered.

Distribution of time between exploit contract deployment and the actual attack trigger, showing a significant window for preemptive action.

As shown in the data, many attackers deploy their contracts minutes or even days before execution. This provides a massive opportunity for "preemptive hijacking" that traditional frontrunning, which only reacts to the trigger transaction, completely misses. By treating the attacker’s own code as a blueprint, BACKRUNNER can rescue funds without needing to manually reverse-engineer the underlying vulnerability.

Results and Impact

The authors evaluated BACKRUNNER using historical data from 158 real-world attacks between January 2023 and May 2024. The results highlight the limitations of current technology: 89% of these attacks bypassed public mempools entirely, rendering traditional frontrunning useless.

In backtesting, BACKRUNNER demonstrated the potential to rescue over $410 million. During a two-month live deployment across Ethereum, BSC, Base, and Polygon, the system successfully mitigated 28 separate incidents, rescuing $11.2 million. The system is highly efficient, with exploit cloning and rewrites typically finishing in under 300ms, allowing for reaction within the timeframe of a single block.

Conclusion and Future Work

BACKRUNNER represents a significant shift in DeFi security, moving from reactive competition to proactive exploit repurposing. While highly effective, limitations remain, such as attacks using generic "launchpad" contracts or atomic transactions where deployment and execution occur in the same private bundle. Future work will explore the use of LLM-guided fuzzing to solve complex numerical inputs required for certain high-precision exploits, further narrowing the window for attackers.

Summary updated

BibTeX
@misc{shou2024backrunner,
  author = {Chaofan Shou and Yuanyu Ke and Yupeng Yang and Qi Su and Or Dadosh and Assaf Eli and David Benchimol and Doudou Lu and Daniel Tong and Dex Chen and Zoey Tan and Jacob Chia and Koushik Sen and Wenke Lee},
  title = {{BACKRUNNER: Mitigating Smart Contract Attacks in the Real World}},
  year = {2024},
  eprint = {2409.06213},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2409.06213},
}
Figure