-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
claimAuction will be permanently DoS'd if there are too many participants due to gas limit #185
Comments
141345 marked the issue as duplicate of #1952 |
alex-ppg marked the issue as duplicate of #2038 |
alex-ppg marked the issue as unsatisfactory: |
Hi @alex-ppg, This is not a duplicate of H-01 , which states that attacker can increase the array length by himself (mentioned at the start of the issue). If the attacker increases the array length to DoS auction, bidders can simply not participate in the auction. This issue is about logic failure instead of attack griefing due to genuine auction behaviour. If many people participate in the auction (given the condition that auction time is long, auction prices are low, people are interested in getting the NFT, and they do not reclaim their funds back before the auction ends), the claim function right at the very end will never be able to run because function is out of gas. Most of the duplicated issues talk about attacker growing the array size, which is a duplicate of H-01. Some issues that are like mine are those that are not talking about attackers, like #1851, #435, #639, #1200 Thank you for your time! |
Hey @cryptostaker2, thanks for bringing this to my attention. Regardless of the rationalization of the severity or the way that the array size increases, the root cause of all duplicated vulnerabilities is that the array increases its size in an unbounded way, resulting in a DoS attack. The bot report that caused this and relevant submissions to be OOS denotes the root cause and marks it as "high-severity", meaning that it has been aptly given the attention it needs. If the Sponsor corrects the issue described in the relevant bot report, this attack / natural DoS will no longer be possible. As the root cause has been identified by the bot report, I am inclined to mark any vulnerability arising from it (regardless of how it results in a high size) to be OOS. |
Lines of code
https://github.com/code-423n4/2023-10-nextgen/blob/8b518196629faa37eae39736837b24926fd3c07c/smart-contracts/AuctionDemo.sol#L104-L120
Vulnerability details
Impact
If there are too many participants,
claimAuction()
cannot be called due to gas limit, which results in permanent denial of service. Non-winners will not be able to get their ETH back. The winner cannot get his NFT and the NFT owner cannot get his money.Proof of Concept
This issue builds on top of [H-01] in the automated report. In the report, it mentions
Although theoretically true, the reported issue is extremely difficult to achieve because of how big uint256 is.
In this issue however, it only takes about 4000 genuine participants in an auction to permanently DoS the
claimAuction()
function.Let's look at how the auction works.
Whenever a participant has a bid higher than the previous highest bid, their participation will be sored in the
auctionInfoData
mapping.The participant can choose to cancel their bid and reclaim their ETH through
cancelBid()
andcancelAllBids()
, provided that the auction has not ended. Otherwise, they can only reclaim their ETH whenclaimAuction()
is called by either the winner or the admin.The issue lies in the gas cost for refunding all the bids. If there are too many participants to refund, the
claimAuction()
function will reach ETH gas limit, which is 30 million, and will result in a permanent DoS.Take a look at the simple contract below, and run it on Remix. Call deposit with some ETH to deposit ETH into the contract.
The number of runnable loop in the actual protocol will be a lot less than 4200 because of all the additional checks involved in
claimAuction()
, but this shows that if there is ~4000 participants in an auction that didn't cancel their bid, theclaimAuction()
function will be permanently DoS'd. 4000 genuine participants is not that impossible to achieve, unlike reaching uint256 value.Users cannot get back their ETH and the winner cannot get his NFT. Worst still, it looks like the ETH will be stuck in the contract since there is no function to withdraw ETH from the contract.
Tools Used
Remix
Recommended Mitigation Steps
Assessed type
DoS
The text was updated successfully, but these errors were encountered: