Skip to content
DoS Audit finding Intermediate

The reveal process could brick if randProvider stops working

The contract's reveal process can become permanently stuck if the random seed provider stops responding after a seed request is made, because the only way to clear the waiting state is for that same provider to call back. This would prevent any new gobblers from being revealed and leave them unable to mint goo.

zzykxx Follow

Originally disclosed on Code4rena

Submitted by zzykxx, also found by 8olidity, berndartmueller, bin2chen, bytehat, devtooligan, hansfriese, IllIllI, imare, Lambda, obront, philogy, shung, tonisives, zdhu, and zkhorse

It could become impossible to reveal gobblers which leads any new minted gobbler to have an emissionMultiple of 0 forever, preventing them from minting any goo.

Proof of Concept

In ArtGobblers.sol calling requestRandomSeed() sets gobblerRevealsData.waitingForSeed = true, which makes both revealGobblers() and upgradeRandProvider() revert.

The only way to set gobblerRevealsData.waitingForSeed = false is by calling acceptRandomSeed() which can only be called by the randProvider itself.

This means that if randProvider stops working and requestRandomSeed() is called (which sets gobblerRevealsData.waitingForSeed = true) there is no way for upgradeRandProvider() and revealGobblers() to be ever called again.

Copy the test in RandProvider.t.sol and run it with forge test -m testRandomnessBrick:

function testRandomnessBrick() public {
    vm.warp(block.timestamp + 1 days);
    mintGobblerToAddress(users[0], 1);

    bytes32 requestId = gobblers.requestRandomSeed();

    /*
        At this point we should have
        vrfCoordinator.callBackWithRandomness(requestId, randomness, address(randProvider));

        But that doesn't happen because we are assuming
        randProvider stopped responding
    /*

    /*
        Can't reveal gobblers
    */
    vm.expectRevert(ArtGobblers.SeedPending.selector);
    gobblers.revealGobblers(1);

    /*
        Can't update provider
    */
    RandProvider newRandProvider = new ChainlinkV1RandProvider(
        ArtGobblers(address(gobblers)),
        address(vrfCoordinator),
        address(linkToken),
        keyHash,
        fee
    );

    vm.expectRevert(ArtGobblers.SeedPending.selector);
    gobblers.upgradeRandProvider(newRandProvider);
}

Recommended Mitigation Steps

A potential fix is to reset some variables in upgradeRandProvider instead of reverting:

function upgradeRandProvider(RandProvider newRandProvider) external onlyOwner {
    if (gobblerRevealsData.waitingForSeed) {
        gobblerRevealsData.waitingForSeed = false;
        gobblerRevealsData.toBeRevealed = 0;
        gobblerRevealsData.nextRevealTimestamp = uint64(nextRevealTimestamp - 1 days);
    }

    randProvider = newRandProvider; // Update the randomness provider.

    emit RandProviderUpgraded(msg.sender, newRandProvider);
}

This gives a little extra powers to the owner, but I don’t think it’s a big deal considering that he can just plug in any provider he wants anyway.

Alex the Entreprenerd (judge) commented:

The Warden has highlighted a risk with the state handling that concerns receiving randomness from the randProvider. As detailed, if no callback is performed, this would put the contract in a state where the faulty provider could not be replaced.

While no specific way for the provider to be bricked was given, if we assume that the provider was retired or deprecated, the contract may fall in such a situation.

Because this is contingent on an externality, but would deny a core functionality of the protocol, I agree with Medium Severity.

FrankieIsLost (Art Gobblers) commented:

Agree, thanks. Fixed here: https://github.com/artgobblers/art-gobblers/pull/154


The original report as published on Code4rena, by zzykxx. 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 sets a waiting flag when requesting randomness and only allows the same provider to clear it, so a non-responsive provider permanently blocks both revealing and provider replacement.

Impact

If the random provider stops responding, the reveal process is permanently blocked, so new gobblers cannot be revealed and will have an emissionMultiple of zero, preventing them from minting goo.

What the attacker needed

RandProvider stops responding; requestRandomSeed() has been called

The fix

The owner should be able to reset the waiting state and related variables when upgrading the random provider, rather than the upgrade reverting.

How it was found

  1. Mint a gobbler to a user.
  2. Call requestRandomSeed() to set waitingForSeed to true.
  3. Assume the randProvider never calls back with randomness.
  4. Attempt to reveal gobblers, which reverts with SeedPending.
  5. Attempt to upgrade the randProvider, which also reverts with SeedPending.

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 asks an outside service for a random number to reveal new digital collectibles. If that service goes silent after being asked, the contract gets stuck waiting forever and cannot switch to a new service or reveal any collectibles. This means newly created collectibles can never start producing the in-game currency.

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 zzykxx

View all

6 more disclosed reports, best first.

More from Art Gobblers 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.