Auction winner can return his bid #1212
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-1323
satisfactory
satisfies C4 submission criteria; eligible for awards
Lines of code
https://github.com/code-423n4/2023-10-nextgen/blob/main/smart-contracts/AuctionDemo.sol#L105
Vulnerability details
Vulnerability Details
Prerequisites:
getAuctionEndTime
is a validblock.timestamp
(1/12 chance if selected in random, see more in this answer)Steps by the attacker:
block.timestamp == minter.getAuctionEndTime(_tokenid)
. For example using minTimestamp & maxTimestamp parameters, allowed, see docs. Or just calculate desired block number and use itclaimAuction
cancelBid
inonERC721Received
Impact
Attacker returns their bid and gets the NFT
Proof of Concept
Put the contract below in hardhat/smart-contracts
Put the test file below to
hardhat/tests/fileName.test.js
and runnpx hardhat test test/fileName.test.js
Tools Used
Manual review
Recommended Mitigation Steps
Change
>=
to>
inblock.timestamp >= minter.getAuctionEndTime(_tokenid)
inclaimAuction
Add
nonReentrant
modifiersAssessed type
Timing
The text was updated successfully, but these errors were encountered: