Closed c4-submissions closed 1 year ago
141345 marked the issue as duplicate of #962
alex-ppg marked the issue as duplicate of #1323
alex-ppg marked the issue as partial-50
alex-ppg marked the issue as full credit
alex-ppg marked the issue as partial-50
Lines of code
https://github.com/code-423n4/2023-10-nextgen/blob/8b518196629faa37eae39736837b24926fd3c07c/smart-contracts/AuctionDemo.sol#L104 https://github.com/code-423n4/2023-10-nextgen/blob/8b518196629faa37eae39736837b24926fd3c07c/smart-contracts/AuctionDemo.sol#L124
Vulnerability details
Impact
claimAuction
function ofAuctionDemo
contract transfers the token to highest bidder (winner) and the bid amount is transferred to the owner. Moreover, refund is sent to all remaining participants (non-winners) of the auction viacall
function. However, if a non-winner is a contract, then it can invoke thecancelBid
function when refund is sent to it. This way, the attacker can get the refund twice; once by theclaimAuction
function and secondly bycancelBid
function.Proof of Concept
claimAuction
function exactly on the auction end time (i.e block.timestamp == AuctionEndTime), this causes the following condition to become true :-require(block.timestamp >= minter.getAuctionEndTime(_tokenid)...
call
and the attacker invokes thecancelBid
function and his bid is cancelled as following condition is also still true :-function cancelBid(uint256 _tokenid, uint256 index) public { require(block.timestamp <= minter.getAuctionEndTime(_tokenid), "Auction ended");
(bool success, ) = payable(auctionInfoData[_tokenid][index].bidder).call{value: auctionInfoData[_tokenid][index].bid}("");
Same is also
Tools Used
Manual Review
Recommended Mitigation Steps
Line 115 should change the status to false before sending refund
} else if (auctionInfoData[_tokenid][i].status == true) {
Moreover, remove equality from the condition in
cancelBid
functionrequire(block.timestamp < minter.getAuctionEndTime(_tokenid), "Auction ended");
or remove equality from the condition inclaimAuction
functionrequire(block.timestamp > minter.getAuctionEndTime(_tokenid)...
Assessed type
Reentrancy