本文へ移動
Contact

TECHFUND
Media

Hi AUDIT
2024/12/23

Comprehensive Analysis of the GemPad $2.2 Million  Exploit

Overview of the Exploit

On December 17, 2024, an exploit targeted GemPad’s V2 lock smart contract, causing significant financial losses across multiple blockchains, including Ethereum, BNB Chain, Base, and Polygon. The attacker leveraged a reentrancy vulnerability in the collectFees function, resulting in the theft of approximately $2.2 million in assets. 

Step-by-Step Breakdown of the Exploit

  1. The attacker deployed a custom malicious token, referred to as T, which held liquidity pool (LP) tokens from an earlier created liquidity position.

  2. The attacker then utilized GemPad’s locklpV3 function to lock a liquidity position. This position, designated as P, contained: T tokens (malicious) LP tokens of the targeted assets.

  3. The attacker executed a swap on Uniswap V3, exchanging a small amount of T tokens for additional LP tokens. While the exact purpose of this step remains unclear, it set the stage for the subsequent exploit.

  4. The attacker called the collectFees function in GemPad’s contract for the P position. This triggered a call to Uniswap V3’s collect function, transferring tokens of the P position to the GemPad contract. At this stage, everything appeared normal.

  5. However, when Uniswap initiated the transfer of T tokens, the malicious token invoked GemPad’s multipleLock function. This behavior exploited a reentrancy vulnerability, allowing the T token to: Deposit previously held LP tokens to create a new locked position in the GemPad contract.

  6. Once the multipleLock function completed, the execution of collectFees resumed. The contract calculated the fees for the P position as the difference between the current balance and the previous balance. This calculation included: Fees genuinely earned by the P position. LP tokens forwarded by the malicious T token.


    As a result, the attacker received their deposited tokens back and secured a locked position for free. This revealed the elegant simplicity of the attack: a classic reentrancy exploit targeting the collectFees function. With each reentrant call, the attacker could withdraw the locked LP amount,

The vulnerability resided in the collectFees function, as shown below:

Attack transactions by Blocksec

Attacker address on Mainnet:

0xFDd9b0A7e7e16b5Fd48a3D1e242aF362bC81bCaa

Attacker address on BSC:

0xFDd9b0A7e7e16b5Fd48a3D1e242aF362bC81bCaa

Attacker address on Base:

0xFDd9b0A7e7e16b5Fd48a3D1e242aF362bC81bCaa

Attack Contract on Mainnet:

0x8e18Fb32061600A82225CAbD7fecF5b1be477c43

Attack Contract on BSC:

0x8e18Fb32061600A82225CAbD7fecF5b1be477c43

Attack Contract on Base:

0x8e18Fb32061600A82225CAbD7fecF5b1be477c43

However, it also notices that they audited this contract two times, once by Solidproof and once by Cyberscope

Explore more hack analyses here

Hi AUDIT

Hi AUDIT is a high speed, high quality, best price security audit service, providing automated audit SaaS and consulting for web3 startups.
View More