A token can be stolen from the auction due to an incorrect condition in the end-time validation #911
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-1323
edited-by-warden
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#L125
https://github.com/code-423n4/2023-10-nextgen/blob/main/smart-contracts/AuctionDemo.sol#L105
Vulnerability details
Impact
A bid can be canceled until the block timestamp is less than or equal to the auction end time.
The winner may claim the token when the block timestamp becomes greater than or equal to the auction end time.
Since the timestamp value is generated by a miner and can be adjusted within a 15-minute range, an attacker could potentially craft a transaction with a timestamp precisely matching the auction end time.
As a result, an attacker has the ability to both claim a token and cancel the bid in a single transaction. In this scenario, some of the other participants may not receive a refund, as there would not be sufficient funds in the contract balance.
In order to reclaim their funds before the auction owner transfers the bid value, the attacker can utilize the
onERC721Received
callback function.Proof of Concept
To test the POC, first initialize a foundry project. In the repository's root folder, execute the following commands:
Next, add the
POC.t.sol
file to thetest
folder.Run test using:
forge test
Tools Used
Manual review
Recommended Mitigation Steps
Assessed type
Invalid Validation
The text was updated successfully, but these errors were encountered: