Auction can be bricked by a malicious user #81
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
duplicate-739
edited-by-warden
partial-50
Incomplete articulation of vulnerability; eligible for partial credit only (50%)
Lines of code
https://github.com/code-423n4/2023-10-nextgen/blob/main/smart-contracts/AuctionDemo.sol#L104-L120
Vulnerability details
Impact
The
claimAuction()
function in theAuctionDemo.sol
contract can be bricked by malicious user resulting in all funds being locked in theAuctionDemo.sol
contract. A malicious user can just create a simple contract and use it to win the bidding. He can wait for the last seconds and place a bid that is bigger than the previous with just one wei. The problem comes because withinclaimAuction()
IERC721(gencore).safeTransferFrom(ownerOfToken, highestBidder, _tokenid);
. SafeTransferFrom checks if thehighestBidder
is a contract. IfhighestBidder
is a contract in order to receive the NFT it has to implement the following function:Simply creating a contract that doesn't have this function and winning the auction with said contract, will result in the
claimAuction()
reverting. I have chosen the High severity because all bidders will lose their funds, and additionally the protocol team has specified the following invariant: "The highest bidder will receive the token after an auction finishes, the owner of the token will receive the funds and all other participants will get refunded."Proof of Concept
To run the POC first follow the steps in this link: https://hardhat.org/hardhat-runner/docs/advanced/hardhat-and-foundry in order to add foundry to the project.
Create a
AuditorTests.t.sol
file in the test folder and add the following to it:Create a file named
BrickContract.sol
in the test folder and add the following to it:To run the test use:
forge test -vvv --mt test_BrickAuctionDemo
Tools Used
Foundry & Manual review
Recommended Mitigation Steps
Consider adding separate functions where the other bidders can withdraw the amount they have bid after the Auction is completed, as well as add such function for the NFT owner that put their NFT for an auction, so he can withdraw his earnings. Consider utilizing the Pull over Push pattern https://fravoll.github.io/solidity-patterns/pull_over_push.html
Assessed type
Token-Transfer
The text was updated successfully, but these errors were encountered: