Core Contracts

Regnum Aurum Acquisition Corp
HardhatReal World AssetsNFT
77,280 USDC
View results
Submission Details
Severity: medium
Invalid

Front-Running Could Lead to Unfair Bidding and Auction Manipulation

Description

The buy function in the smart contract is vulnerable to front-running attacks. This occurs because the function updates the auction state (e.g., state.lastBidTime, state.lastBidder) based on block.timestamp and msg.sender. Attackers can exploit this by monitoring the mempool for pending transactions and submitting their own transactions with higher gas fees to outbid legitimate users.

Affected Code

The vulnerability is present in the following lines of the buy function:

state.lastBidTime = block.timestamp;
state.lastBidder = msg.sender;

Vulnerability Details

  1. A legitimate user submits a transaction to call buy with a specific amount.

  2. An attacker observes this transaction in the mempool.

  3. The attacker quickly submits their own transaction with a higher gas fee, calling buy with the same or a larger amount.

  4. The attacker's transaction is mined first due to the higher gas fee, updating the auction state (e.g., state.lastBidder and state.lastBidTime).

  5. The legitimate user's transaction is mined afterward, but the state has already been updated by the attacker, rendering the user's bid ineffective.

Impact

  1. Unfair Bidding: Legitimate users may lose out on bids despite being the first to submit their transactions.

  2. Auction Manipulation: Attackers can systematically exploit this vulnerability to control the auction outcome, potentially acquiring ZENO tokens at the expense of other participants.

  3. Loss of Trust: Users may lose confidence in the fairness of the auction mechanism, harming the protocol's reputation.

Exploit Scenario

  1. Alice wants to buy 100 ZENO tokens and submits a transaction with a reasonable gas fee.

  2. Bob, an attacker, monitors the mempool and sees Alice's transaction.

  3. Bob submits his own transaction to buy 100 ZENO tokens but with a higher gas fee.

  4. Bob's transaction is mined first, making him the state.lastBidder and updating state.lastBidTime.

  5. Alice's transaction is mined afterward, but her bid is effectively ignored because Bob's transaction already updated the state.

Tools Used

  • Manual Review

Recommended Mitigation Steps

To mitigate front-running, consider implementing one or more of the following solutions:

1. Commit-Reveal Scheme

  • How It Works:

    1. Users first submit a commitment (e.g., a hash of their bid amount and a secret) in a commit phase.

    2. In a subsequent reveal phase, users reveal their actual bid amount and secret.

    3. The contract verifies that the revealed data matches the commitment and processes the bid.

  • Advantage: Prevents front-running because attackers cannot see the actual bid details during the commit phase.

2. Use of a VRF (Verifiable Random Function)

  • How It Works:

    1. Use a decentralized oracle (e.g., Chainlink VRF) to generate a random number that determines the order of bids.

    2. Bids are processed based on the random number, making it impossible for attackers to predict or manipulate the outcome.

  • Advantage: Ensures fairness and eliminates front-running.

Updates

Lead Judging Commences

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.