The end
function fails to reset the highest_bidder
's balance in the bid_values
mapping to zero after transferring the NFT. This oversight allows the highest bidder to withdraw their funds even after receiving the auctioned NFT, potentially leading to a double-spend scenario.
The vulnerability is located in the end
function of the StarknetAuction
contract. After the auction ends and the NFT is transferred to the highest bidder, the function does not update the bid_values
mapping for the highest bidder. As a result, the highest bidder's balance remains unchanged in the contract's state.
This vulnerability can lead to a severe financial loss for the auction contract. The highest bidder can exploit this oversight by:
Winning the auction and receiving the NFT.
Calling the withdraw
function to retrieve their bid amount.
This results in the highest bidder obtaining both the NFT and their original bid amount, effectively allowing them to acquire the NFT for free and depleting the contract of funds meant for the NFT owner.
Manual review
In the end
function, add a line to reset the highest bidder's balance in the bid_values
mapping:
Consider adding a check in the withdraw
function to ensure that the highest bidder cannot withdraw funds after the auction has ended:
The `withdraw` function allows the participants to receive back the value of all their unsuccessful bids. The problem is that the winner of the auction will receive all bids including the `highest_bid` that should be paid to the NFT owner.
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.