Permanent DoS due to non-shrinking array usage in an unbounded loop
An auction contract stores every bid in an array that never shrinks, and several functions loop over the whole array. An attacker could submit many tiny bids so those loops run out of gas, permanently blocking functions such as claiming the auction.
Submitted by Hound
Note: this finding was reported via the winning Automated Findings report. It was declared out of scope for the audit, but is being included here for completeness.
There are some arrays that can grow indefinitely in size, as they never shrink. When these arrays are used in unbounded loops, they may lead to a permanent denial-of-service (DoS) of these functions.
POC
- Attacker calls
participateToAuctionN times with dust amounts untilreturnHighestBidreverts (out of gas). - When
claimAuctionis called byWinnerOrAdminRequired, the transaction will fail, as it callsreturnHighestBid. As a result,claimAuctionwill be permanently DoS.
There are 4 instances of this issue:
File: smart-contracts/AuctionDemo.sol
// @audit function returnHighestBid is vulnerable as length grows in size but never shrinks
69: for (uint256 i=0; i< auctionInfoData[_tokenid].length; i++) {
60: auctionInfoData[_tokenid].push(newBid);
// @audit function returnHighestBidder is vulnerable as length grows in size but never shrinks
90: for (uint256 i=0; i< auctionInfoData[_tokenid].length; i++) {
60: auctionInfoData[_tokenid].push(newBid);
// @audit function claimAuction is vulnerable as length grows in size but never shrinks
110: for (uint256 i=0; i< auctionInfoData[_tokenid].length; i ++) {
60: auctionInfoData[_tokenid].push(newBid);
// @audit function cancelAllBids is vulnerable as length grows in size but never shrinks
136: for (uint256 i=0; i<auctionInfoData[_tokenid].length; i++) {
60: auctionInfoData[_tokenid].push(newBid);
Important and valid.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the bid history array only ever grows, and functions iterate over its full length without a bound, so gas cost rises with attacker-controlled entries.
Impact
The affected auction functions could be permanently unusable, so winners may be unable to claim and bids may not be cancellable.
What the attacker needed
Ability to submit many small bids; paying gas for each bid
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A smart contract keeps a list of every bid ever made for an item, and it never removes old entries. Some actions read the whole list, and each read costs a small fee (gas). By adding thousands of tiny bids, an attacker makes those actions too expensive to complete, so they always fail.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.