Skip to content
DoS Audit finding Advanced

Anyone can pause AuctionHouse in _createAuction

The auction contract's internal auction-creation routine wraps the NFT mint in a try/catch that pauses the whole contract on any failure, including running out of gas. Because minting copies creator lists and metadata into storage, an attacker can craft an art piece whose minting costs more gas than the fixed threshold, so a normal settle call runs out of gas and pauses the AuctionHouse.

bart1e Follow with wintermute, Tricko and 3 others

Originally disclosed on Code4rena

Submitted by bart1e, also found by wintermute, Tricko, 0xDING99YA, Ryonen (1, 2), 00xSEV, and hals

https://github.com/code-423n4/2023-12-revolutionprotocol/blob/d42cc62b873a1b2b44f57310f9d4bbfdd875e8d6/packages/revolution/src/AuctionHouse.sol#L328

https://github.com/code-423n4/2023-12-revolutionprotocol/blob/d42cc62b873a1b2b44f57310f9d4bbfdd875e8d6/packages/revolution/src/AuctionHouse.sol#L311-L313

https://github.com/code-423n4/2023-12-revolutionprotocol/blob/d42cc62b873a1b2b44f57310f9d4bbfdd875e8d6/packages/revolution/src/VerbsToken.sol#L292-L310

Any user can call AuctionHouse::settleCurrentAndCreateNewAuction in order to settle the old auction and create a new one. settleCurrentAndCreateNewAuction will call _createAuction, which code is shown below:

    function _createAuction() internal {
        // Check if there's enough gas to safely execute token.mint() and subsequent operations
        require(gasleft() >= MIN_TOKEN_MINT_GAS_THRESHOLD, "Insufficient gas for creating auction");

        try verbs.mint() returns (uint256 verbId) {
            uint256 startTime = block.timestamp;
            uint256 endTime = startTime + duration;

            auction = Auction({
                verbId: verbId,
                amount: 0,
                startTime: startTime,
                endTime: endTime,
                bidder: payable(0),
                settled: false
            });

            emit AuctionCreated(verbId, startTime, endTime);
        } catch {
            _pause();
        }
    }

As we can see, it will try to mint an NFT, but if it fails, it will execute the catch clause. Sponsors are already aware that catch block would also catch deliberate Out Of Gas exceptions and that is why require(gasleft() >= MIN_TOKEN_MINT_GAS_THRESHOLD) is present in the code (MIN_TOKEN_MINT_GAS_THRESHOLD = 750_000). However, it is still possible to consume a lot of gas in verbs.mint and force the catch clause to execute, and, in turn, pause the contract.

In order to see it, let’s look at the code of VerbsToken::mint:

    function mint() public override onlyMinter nonReentrant returns (uint256) {
        return _mintTo(minter);
    }

It will call _mintTo:

    function _mintTo(address to) internal returns (uint256) {
       [...]
        // Use try/catch to handle potential failure
        try cultureIndex.dropTopVotedPiece() returns (ICultureIndex.ArtPiece memory _artPiece) {
            artPiece = _artPiece;
            uint256 verbId = _currentVerbId++;

            ICultureIndex.ArtPiece storage newPiece = artPieces[verbId];

            newPiece.pieceId = artPiece.pieceId;
            newPiece.metadata = artPiece.metadata;
            newPiece.isDropped = artPiece.isDropped;
            newPiece.sponsor = artPiece.sponsor;
            newPiece.totalERC20Supply = artPiece.totalERC20Supply;
            newPiece.quorumVotes = artPiece.quorumVotes;
            newPiece.totalVotesSupply = artPiece.totalVotesSupply;

            for (uint i = 0; i < artPiece.creators.length; i++) {
                newPiece.creators.push(artPiece.creators[i]);
            }

            _mint(to, verbId);

            [...]
    }

As can be seen, it performs some costly operations in terms of gas:

  • cultureIndex.dropTopVotedPiece() may be costly if there are many art pieces in the MaxHeap - height of MaxHeap is O(log n), where n is the number of elements, but dropTopVotedPiece may iterate over the entire height and each time it will read and write storage memory, which is expensive.
  • newPiece.metadata = artPiece.metadata; can be very costly when artPiece.metadata is big (currently, it can have an arbitrary size, so this operation may be very costly).
  • newPiece.creators.push(artPiece.creators[i]); is writing to storage in a loop, which is expensive as well.

Although all above mentioned operations could be used in order to cause OOG exception, I will focus only on the third one - as I will show in the PoC section, if 10 creators are specified (which is a reasonable number) and even a small art piece (containing only a short URL and short description), the attack is possible as pushes will consume over 750 000 gas. It shows that the attack can be performed very often - probably in case of majority of auctions that are ready to be started (as many of art pieces will have several creators or slightly longer descriptions).

Impact

Malicious users will be able to often pause the AuctionHouse contract - they don’t even need for their art piece to win the voting as the attack will be likely possible even on random art pieces.

Of course, the owner (DAO) will still be able to unpause the contract, but until it does so (the proposal would have to be first created and voted, which takes time), the contract will be paused and impossible to use. The upgrade of AuctionHouse contract will be necessary in order to recover.

Proof of Concept

The test below demonstrates how an attacker can cause _createAuction to execute catch clause causing AuctionHouse to pause itself when it shouldn’t as there is another art piece waiting to be auctioned.

Please put the following test into AuctionSettling.t.sol and run it:

    // create an auction with a piece of art with given number of creators and finish it
    function _createAndFinishAuction() internal
    {
        uint nCreators = 10;
        address[] memory creatorAddresses = new address[](nCreators);
        uint256[] memory creatorBps = new uint256[](nCreators);
        uint256 totalBps = 0;
        address[] memory creators = new address[](nCreators + 1);
        for (uint i = 0; i < nCreators + 1; i++)
        {
            creators[i] = address(uint160(0x1234 + i));
        }

        for (uint256 i = 0; i < nCreators; i++) {
            creatorAddresses[i] = address(creators[i]);
            if (i == nCreators - 1) {
                creatorBps[i] = 10_000 - totalBps;
            } else {
                creatorBps[i] = (10_000) / (nCreators - 1);
            }
            totalBps += creatorBps[i];
        }

        // create the initial art piece
        uint256 verbId = createArtPieceMultiCreator(
            "Multi Creator Art",
            "An art piece with multiple creators",
            ICultureIndex.MediaType.IMAGE,
            "ipfs://multi-creator-art",
            "",
            "",
            creatorAddresses,
            creatorBps
        );

        vm.startPrank(auction.owner());
        auction.unpause();
        vm.stopPrank();

        uint256 bidAmount = auction.reservePrice();
        vm.deal(address(creators[nCreators]), bidAmount + 1 ether);
        vm.startPrank(address(creators[nCreators]));
        auction.createBid{ value: bidAmount }(verbId, address(creators[nCreators]));
        vm.stopPrank();

        vm.warp(block.timestamp + auction.duration() + 1); // Fast forward time to end the auction

        // create another art piece so that it's possible to create next auction
        createArtPieceMultiCreator(
            "Multi Creator Art",
            "An art piece with multiple creators",
            ICultureIndex.MediaType.IMAGE,
            "ipfs://multi-creator-art",
            "",
            "",
            creatorAddresses,
            creatorBps
        );
    }

    function testDOS4() public
    {
        vm.startPrank(cultureIndex.owner());
        cultureIndex._setQuorumVotesBPS(0);
        vm.stopPrank();

        _createAndFinishAuction();

        assert(auction.paused() == false);
        // 2 900 000 will be enough to perform the attack
        auction.settleCurrentAndCreateNewAuction{ gas: 2_900_000 }();
        assert(auction.paused());
    }

Tools Used

VS Code

Recommended Mitigation Steps

Preventing OOG with MIN_TOKEN_MINT_GAS_THRESHOLD will not work as, I have shown before, there are at least 3 ways for attackers to boost the amount of gas used in VerbsToken::mint.

In order to fix the issue, consider changing catch to catch Error(string memory) that will not catch OOG exceptions.

rocketman-21 (Revolution) confirmed

0xTheC0der (Judge) commented:

Warden identified 3 main gas griefing attack vectors:

As can be seen, it performs some costly operations in terms of gas:

  • cultureIndex.dropTopVotedPiece() may be costly if there are many art pieces in the MaxHeap - height of MaxHeap is O(log n), where n is the number of elements, but dropTopVotedPiece may iterate over the entire height and each time it will read and write storage memory, which is expensive
  • newPiece.metadata = artPiece.metadata; can be very costly when artPiece.metadata is big (currently, it can have an arbitrary size, so this operation may be very costly)
  • newPiece.creators.push(artPiece.creators[i]); is writing to storage in a loop, which is expensive as well

Although all above mentioned operations could be used in order to cause OOG exception, …

With a subsequent impact of pausing the AuctionHouse.

Issues which partially identified the underlying core issues will be awarded partial credit.

After reviewing comments and (former) duplicates, I agree with this the most:

  • Pausing AuctionHouse by deliberately causing OOG exception.
  • DoSing AuctionHouse by specifying many creators (possibly with griefing receive functions).
  • DoSing AuctionHouse by creating art piece with heavy metadata.

All those vulnerabilities have different core issues which require different mitigation steps. Therefore de-duplicated accordingly.

Note: See full discussion here.


The original report as published on Code4rena, by bart1e. 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

Likely the catch-all try/catch around verbs.mint() treats any failure, including out-of-gas, as a reason to pause, while the gas floor check is too low compared with the unbounded storage writes done during minting.

Impact

An attacker can repeatedly pause the AuctionHouse, blocking auctions until the DAO passes a proposal to unpause, and an upgrade of the contract is needed to recover.

What the attacker needed

Ability to submit an art piece; art piece with many creators; auction ready to settle

How it was found

  1. Create an art piece with ten creators and finish its auction so a new auction is due.
  2. Create a second art piece so the next auction can be started.
  3. Call settleCurrentAndCreateNewAuction with a limited gas amount.
  4. Observe that the contract pauses itself instead of starting the new auction.

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 contract mints a new NFT for the next auction. That minting step is wrapped in a safety net that pauses the whole auction house if anything goes wrong. The author shows that a piece of art with many creators makes the minting step expensive enough to run out of gas, which trips the safety net and freezes auctions for everyone.

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 bart1e

View all

8 more disclosed reports, best first.

More from Revolution Protocol

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.