Art Gobblers contest - yixxas's results

Experimental Decentralized Art Factory By Justin Roiland and Paradigm.

General Information

Platform: Code4rena

Start Date: 20/09/2022

Pot Size: $100,000 USDC

Total HM: 4

Participants: 109

Period: 7 days

Judge: GalloDaSballo

Id: 163

League: ETH

Art Gobblers

Findings Distribution

Researcher Performance

Rank: 91/109

Findings: 1

Award: $55.20

🌟 Selected for report: 0

🚀 Solo Findings: 0

Lines of code

https://github.com/code-423n4/2022-09-artgobblers/blob/d2087c5a8a6a4f1b9784520e7fe75afa3a9cbdbe/src/ArtGobblers.sol#L411

Vulnerability details

Impact

Legendary gobbler cannot be minted when the cost of minting is too high. In mintLegendaryGobbler() function, loop is run through all the gobblers used for the sacrifice. This is an expensive gas operation when cost is too high. In this case, it will exceed the block gas limit of 30 million gas when a user is attempting to mint the last legendary gobbler.

ArtGobblers.sol#L411

    function mintLegendaryGobbler(uint256[] calldata gobblerIds) external returns (uint256 gobblerId) {
            ...

            uint256 id; // Storing outside the loop saves ~7 gas per iteration.

            for (uint256 i = 0; i < cost; ++i) {
                id = gobblerIds[i];

                if (id >= FIRST_LEGENDARY_GOBBLER_ID) revert CannotBurnLegendary(id);

                require(getGobblerData[id].owner == msg.sender, "WRONG_FROM");

                burnedMultipleTotal += getGobblerData[id].emissionMultiple;

                emit Transfer(msg.sender, getGobblerData[id].owner = address(0), id);
            }
    ...
    }

Proof of Concept

LEGENDARY_SUPPLY = 10 LEGENDARY_GOBBLER_INITIAL_START_PRICE = 69 gobblers

The cost doubles for each subsequent ones so we have, in the final iteration, cost = 69 * 2**10 = 70656 so gobblerIds[].length = 70656 and foundry gas estimation to call mintLegendaryGobblers(gobblerIds[]) is at the cost of 35 million gas > 30 million gas.

Minters will have to wait till the cost drops below some amount such that the block gas limit is not exceeded.

Tools Used

Foundry

I see no simple fix for this without compromising on the cost increase of legendary gobblers or the starting cost since every gobblers sacrificed need to be looped through to check their validity and emissions.

#0 - Shungy

2022-09-27T19:27:15Z

There is more nuance to that. First of all the final interval would be 69 * 2**9. But that is impossible, as it requires the previous interval to had 69 * 2**8. These all exceed maximum supply hence will never be reached. You have to also take into burned gobblers into consideration by removing from the maximum supply. Based on those I have calculated the maximum theoretical cost to be around ~4k. It might still get away without reaching gas limit, but it is very close, hence risky. It will probably get even more expenisve (hence riskier) after the "free legendary mint" bug is fixed.

This finding is similar to mine: https://github.com/code-423n4/2022-09-artgobblers-findings/issues/326 But it misses the nuance, and the actual problem. DOS is temporary as cost will decrease with dutch auction. The real issue is that it will shorten the auction interval. And that issue is definitely not high risk. So I will thumbs down this even though it seems similar to my submission on first glance.

#1 - GalloDaSballo

2022-10-09T22:14:45Z

<img width="676" alt="Screenshot 2022-10-10 at 00 14 29" src="https://user-images.githubusercontent.com/13383782/194781950-fbb5a2e0-727c-45ee-a9fd-50043547ac0d.png">

I think the finding is a dup of #326 per the text above

L

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter