Skip to content
DoS Audit finding Intermediate

Try-catch block at Auction._createAuction() will only catch string errors

The _createAuction function wraps token.mint() in a try-catch block that only catches string errors, so custom errors or arithmetic errors from mint() are not caught. If mint() reverts with a custom error, the auction is not settled and the contract may become stuck until the owner pauses it.

0xA5DF Follow

Originally disclosed on Code4rena

Submitted by 0xA5DF

Auction.sol#L234

The _createAuction function wraps the token.mint() call in a try-catch block, however this will only catch reverts that comes from the require keyword and not the reverts with custom errors or other kinds of errors (arithmetic over/underflow etc.)

Impact

In case of an error at the mint() function the auction won’t be settled till the owner intervenes and pauses the contract.

Proof of Concept

Here’s a test that proves that catch Error() doesn’t catch custom errors (the test will fail):

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import "forge-std/Test.sol";

contract ContractTest is Test {
    function testErr() public{
        Reverter r = new Reverter();
        try r.throwCustomError(){

        }catch Error(string memory) {

        }
    }
}

contract Reverter{
    error  MyErr();

    function throwCustomError() public{
        revert MyErr();
    }
}

Recommended Mitigation Steps

Remove the Error so that it’ll catch any kind of revert:

             // Pause the contract if token minting failed
-        } catch Error(string memory) {
+        } catch  {
             _pause();
         }
     }

Alex the Entreprenerd (judge) commented:

Any revert caused by minting will not be captured.

This means that in the case of a erroneous mint the contract will be effectively bricked (and not paused).

I have considered higher severity, but in lack of clear conditions for revert, I think Medium is appropriate.

iainnash (Nouns Builder) confirmed


The original report as published on Code4rena, by 0xA5DF. 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 catch clause is written as catch Error(string memory), which only catches string-based reverts and not custom errors or other revert types.

What the attacker needed

Mint() reverts with a custom error

The fix

Remove the Error(string memory) from the catch clause so that it catches any kind of revert.

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.

In Solidity, a try-catch block can be written to catch only certain kinds of errors. Here, the catch clause only handles errors that include a text message (string errors), so other errors like custom errors or arithmetic overflows slip through. If such an error happens during minting, the auction does not get settled and the contract may be stuck.

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 0xA5DF

View all

35 more disclosed reports, best first.

More from Nouns Builder contest

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.