The withdraw
function allows users (including the NFT owner and unsuccessful bidders) to withdraw their bids after the auction ends. However, the contract transfers funds to the caller before updating the internal state, making the contract vulnerable to a reentrancy attack.
In the withdraw
function:
The contract transfers tokens (erc20_dispatcher.transfer_from
) before removing or resetting the user’s bid amount in storage (self.bid_values
). This allows a malicious contract to reenter the function and call withdraw
multiple times, potentially draining the contract.
An attacker could drain the contract of all funds by calling withdraw
repeatedly, exploiting the fact that the internal state is not updated before the transfer occurs.
Manual code review
Always update the internal state before making any external calls (e.g., token transfers) to prevent reentrancy attacks.
The `withdraw` function doesn't reset the `bid_values` to 0 after the withdraw. That means the bidder can call multiple time the `withdraw` function and receive the whole balance of the protocol.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.