XLinkedInTelegram
Hack Analysis

Breaking Down CloberDEX’s Costly $501K Exploit

Discover how a reentrancy flaw in CloberDEX's Rebalancer contract led to a $501k exploit. Learn the root cause, attack process, and prevention measures.

Author
QuillAudits Team
January 5, 2025
Breaking Down CloberDEX’s Costly $501K Exploit
XLinkedInTelegram

Overview:

The CloberDEX Liquidity Vault was exploited on December 10, 2024, through a reentrancy vulnerability in the _burnfunction of the Rebalancer contract on the Base network. The attacker leveraged a custom malicious strategy that exploited the absence of a reentrancy check, resulting in a loss of approximately 133.7 ETH (~$501,279). The vulnerability arose because the _burn function executed token transfers before updating critical state variables, violating the checks-effects-interactions pattern. By exploiting unmodified reserve values during reentrancy, the attacker manipulated withdrawal calculations to extract more tokens repeatedly.

About Project

Clober is a fully on-chain CLOB DEX protocol for Ethereum and its L2s. Clober presents a new algorithm for order book DEX “LOBSTER - Limit Order Book with Segment Tree for Efficient oRder-matching” that enables on-chain order matching and settlement on decentralized smart contract platforms. With Clober, market participants can place limit and market orders in a fully decentralized, trustless way at a manageable cost.

Exploit Details:

Attack Process:

  • Initially, the attacker took a flash loan of 267 WETH from the Morpho Blue.

    image (54).png

  • The attacker deployed a malicious token contract and created a liquidity pool using the CloberDEX open function.
  • The pool paired WETH with the attacker's custom token, and the attacker set the pool's strategy to point to their attack contract.

    image (55).png

  • The _burn function in the vault’s Rebalancer contract was designed to call an external burnHook function. However, the _burn function lacked reentrancy protection, making it vulnerable to repeated calls.

    image (56).png

  • Within the _burn function, token transfers are were executed before the state variables pool.reserveA and pool.reserveB were updated.
  • This sequence allowed the attacker to exploit the unchanged reserve values to miscalculate withdrawal amounts.
  • During the first execution of the _burn function, the attacker's custom burnHook function reentered the _burn function again before the reserves were updated.
  • This reentrancy enabled the attacker to inflate the withdrawal amounts during the second _burn execution

    Screenshot 2024-12-13 at 17.26.42.png

  • By repeating this process in a single transaction, the attacker siphoned off significantly more tokens than they were entitled to, resulting in the loss of 133.7 ETH.

The Root Cause

The root cause of the CloberDEX Liquidity Vault exploit was the improper handling of external calls in the _burnfunction. Specifically, the _burn function executed token transfers to users before updating critical state variables like pool.reserveA and pool.reserveB. This sequence violated the checks-effects-interactions pattern, leaving the contract vulnerable to reentrancy attacks.

Flow of Funds

See the funds flow here:

1 (3).png

Post Exploit Scenes

CloberDEX responded to the attack and offered the attacker 20% of the stolen funds if the remaining assets are returned.

How could they have prevented the Exploit?

  1. Adding a reentrancy guard, such as OpenZeppelin’s ReentrancyGuard modifier, would have ensured that the _burnfunction could not be called recursively within the same transaction.
  2. The _burn function should update state variables (e.g., pool.reserveA and pool.reserveB) before making external calls like token transfers. This ensures that critical state data is modified before any potential reentrant code execution.
  3. Collaborate with reputable auditors like QuillAudits to analyse smart contracts and identify vulnerabilities.

Why QuillAudits?

Choosing a reputable audit firm like QuillAudits ensures that your protocol undergoes rigorous scrutiny from experienced security professionals. QuillAudits specializes in uncovering critical vulnerabilities and providing actionable remediation strategies. Our expertise helps safeguard your project from attacks, ensuring that security issues are addressed proactively.image-10 (1).png

QuillAudits Team

QuillAudits Team

The QuillAudits team, comprises of expert security researchers & auditors in Web3 security, has completed 1,000+ audits across Ethereum, Polygon, Solana, Arbitrum, BSC, and more, securing $30B+ with 0 exploits, advancing the blockchain ecosystem.

TwitterLinkedInTelegram

Contents

Tell Us About Your Project
Request An Audit
Subscribe to Newsletter
hashing bits image
Loading...

STAY IN THE LOOP

Get updates on our community, partners, events, and everything happening across the ecosystem — delivered straight to your inbox.

Subscribe Now!

newsletter
DeFi SecurityplumeUniswap FoundationAethiropt-collectivePolygon SPNBNB Chain Kickstart

Office 104/105 Level 1, Emaar Square, Building 4 Sheikh Mohammed Bin Rashid Boulevard Downtown Dubai, United Arab Emirates P.O box: 416654

audits@quillaudits.com

All Rights Reserved. © 2025. QuillAudits - LLC

Privacy Policy