本文へ移動
Contact

TECHFUND
Media

Hi AUDIT
2024/3/29

Minerercx Vulnerability Exploited: Understanding the $460k Hack

What Happened?

On February 14, 2024, @minerercx exploited a vulnerability in the Minerercx smart contract, resulting in a significant loss of $460,000.

What is Minerercx?

Minercx is a decentralized platform built on the ERC-X and LayerZero Labs technologies. It allows users to participate in a process called token volatility farming, where they can potentially earn rewards based on the price fluctuations of cryptocurrencies. Minerercx also boasts a collection of 10,000 unique avatars enabled by the ERC-X standard.

The Exploited Vulnerability:

The vulnerability resided within the smart contract's _update function, which is responsible for handling token transfers. This function unfortunately relied on cached balance values for both the sender and recipient of the tokens. This mechanism created a loophole when a user transferred tokens to themselves within the same transaction.

Breaking Down the Vulnerability:

  1. Self-Transfer Trigger: The _update function was triggered with the from and to addresses being identical, signifying a self-transfer.

  2. Cached Values Used: Before the actual transfer took place, the function retrieved the cached balance values for both the sender and recipient (which was the same address in this case).

  3. Double Update: The function then subtracted the transfer amount from the cached sender balance and added the same amount to the cached recipient balance.

  4. Unintended Consequence: Since both cached values pointed to the same address, this operation essentially doubled the user's balance, leading to the exploitation.

Hack transaction :  https://etherscan.io/tx/0x5cc93e9d5adec2b432ddf8052ed77a052e07671db36954675d6f55df28bdb8c0

Impact of the Exploit:

This vulnerability allowed the attacker to manipulate the smart contract and gain unauthorized access to a significant amount of funds, resulting in a loss of $456,000.

Mitigation of this vulnerability

1. Modify the update Function: Adjust the update function within the smart contract to retrieve real-time balance values for both the sender and recipient of the tokens during token transfers. This modification ensures that cached balance values are not relied upon.

2. Add a validation check within the function to ensure that the "address from" which tokens are sent and the "address to" which tokens are sent are never the same within a single transaction.

This incident highlights the importance of thorough smart contract audits and robust security measures in the decentralized finance (DeFi) space.

Written by Piyush shukla

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