Skip to content
DoS Audit finding Intermediate

Adversary can block claimAuction() due to push-strategy to transfer assets to multiple bidders

The claimAuction function uses a push strategy to refund all bidders, which can be blocked by a malicious bidder who makes the external call revert or consume all gas. This locks all funds from the auction, preventing refunds, the owner from receiving earnings, and the winner from getting the NFT.

The_Kakers Follow with TuringConsulting, immeas and 48 others

Originally disclosed on Code4rena

Submitted by The_Kakers, also found by btk (1, 2), TuringConsulting, immeas, yojeff, DeFiHackLabs, audityourcontracts, Toshii, DarkTower, CSL, codynhat, lsaudit, trachev, Vagner, Greed, 0xDetermination, gumgumzum, lanrebayode77, 0xJuda, ke1caM, Al-Qa-qa, Valix, NentoR, glcanvas, CaeraDenoir, MaNcHaSsS, NoamYakov, 0xAsen, mrudenko, innertia, SovaSlava, Talfao, r0ck3tz, 0xlemon, 00xSEV, 0xhunter, VAD37, Arabadzhiev, PENGUN, niki, nmirchev8, flacko, Soul22, ZdravkoHr, 0xpiken, funkornaut, Ruhum, 0xWaitress, Viktor_Cortess, openwide, oualidpro, rvierdiiev, and Haipls

claimAuction() implements a push-strategy instead of a pull-strategy for returning the bidders funds.

This gives the opportunity for an adversary to DOS the function, locking all funds from other participants.

This finding differs from the automated findings report M-01, and L-18, as it has a different root cause, can’t be prevented with any of the mitigations from the bot, and also highlights the actual High impact of the issue.

Impact

  • Prevents other bidders from receiving their bids back.
  • Prevents the token owner from receiving earnings.
  • Prevents the bidder winner from receiving the NFT.

All Ether from the auction can be lost as there is no alternate way of recovering it.

This also breaks one of the main invariants of the protocol:

Properties that should NEVER be broken under any circumstance:

  • 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

An adversary can create bids for as little as 1 wei, as there is no minimum limitation: AuctionDemo.sol#L58. With that, it can participate in as many auctions as they want to grief all auctions.

All non-winning bidders that didn’t cancel their bid before the auction ended will receive their bids back during claimAuction():

    function claimAuction(uint256 _tokenid) public WinnerOrAdminRequired(_tokenid,this.claimAuction.selector){
        /// ...
->      for (uint256 i=0; i< auctionInfoData[_tokenid].length; i ++) {
            if (auctionInfoData[_tokenid][i].bidder == highestBidder && auctionInfoData[_tokenid][i].bid == highestBid && auctionInfoData[_tokenid][i].status == true) {
                IERC721(gencore).safeTransferFrom(ownerOfToken, highestBidder, _tokenid);
                (bool success, ) = payable(owner()).call{value: highestBid}("");
                emit ClaimAuction(owner(), _tokenid, success, highestBid);
            } else if (auctionInfoData[_tokenid][i].status == true) {
->              (bool success, ) = payable(auctionInfoData[_tokenid][i].bidder).call{value: auctionInfoData[_tokenid][i].bid}("");
                emit Refund(auctionInfoData[_tokenid][i].bidder, _tokenid, success, highestBid);
            } else {}
        }
    }

AuctionDemo.sol#L116

The contracts call the bidders with some value. If the receiver is a contract, it can execute arbitrary code. A malicious bidder can exploit this to make the claimAuction() always revert, and so no funds to other participants be paid back.

With the current implementation, a gas bomb can be implemented to perform the attack. L-18 from the automated findings report suggests the use of excessivelySafeCall() to prevent it, but it limits the functionality of legit contract receivers, and eventually preventing them from receiving the funds. In addition, the finding doesn’t showcase the High severity of the issue and may be neglected.

M-01 from the automated findings report points out the lack of a check of the success of the calls. If the function reverts when the call was not successful, the adversary can make a callback on its contract receive() function to always revert to perform this same attack. In addition, this finding also doesn’t showcase the High severity of the issue.

Ultimately the way to prevent this attack is to separate the transfer of each individual bidder to a separate function.

Recommended Mitigation Steps

Create a separate function for each bidder to claim their funds back (such as the cancel bids functions are implemented).

Assessed type

ETH-Transfer

a2rocket (NextGen) acknowledged and commented via duplicate issue #1703:

There are several ways to do this; we will introduce an additional claimingFunction.

0xsomeone (judge) commented:

The Warden specifies a way in which an auction can be sabotaged entirely in its claim operation by gas griefing.

While the finding has been identified as L-18 in the automated findings report, it may indeed be neglected and inadequately encompasses the severity of this flaw.

As the Warden clearly illustrates, all funds in the auction will be permanently lost and in an easily accessible fashion by simply either consuming all gas in meaningless operations or gas-bombing via an arbitrarily large payload being returned.

This particular submission was selected as best-for-report due to its acknowledgment of automated findings issues, precisely & correctly specifying the impact of the exhibit, and providing a PoC that demonstrates the problem.

The C4 Supreme Court verdict did not finalize on issues based entirely on automated findings and as such, I will deem this exhibit a valid high submission given its accessibility and 2-tier upgrade from the automated findings report (L to H).


The original report as published on Code4rena, by The_Kakers. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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

The contract uses a push strategy, sending Ether to all bidders in a loop within claimAuction, so a single malicious bidder can cause the entire transaction to revert.

Impact

All funds from the auction can be permanently locked, preventing refunds to bidders, payment to the owner, and transfer of the NFT to the winner.

What the attacker needed

Adversary can place a bid; adversary uses a contract that reverts on receive; auction ends with adversary as non-winner

The fix

The fix is to use a pull strategy, where each bidder calls a separate function to claim their refund, rather than sending Ether to all bidders in a loop.

How it was found

  1. An adversary creates a bid for as little as 1 wei in an auction.
  2. The adversary's contract is set to revert or consume all gas when it receives Ether.
  3. After the auction ends, claimAuction is called to refund bidders.
  4. The call to the adversary's contract fails or runs out of gas, causing the whole transaction to revert.
  5. All funds remain locked, and other bidders cannot get refunds.

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.

When an auction ends, the smart contract tries to send money back to everyone who bid but did not win. A bad actor can make their own refund fail on purpose, which stops the whole process and traps everyone else's money.

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.

More by The_Kakers

View all

2 more disclosed reports, best first.

More from NextGen

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.