Skip to content
Business logic Audit finding Intermediate

RuniverseLandMinter._mintTokensUsingTokenId does not verify that the tokenId matches the corresponding plotSize

The minting function does not check that the token ID's encoded plot size matches the plot size parameter, allowing the owner to mint plots of a larger size while counting them against a smaller size's limit. This bypasses the per-size supply cap and corrupts the recorded minted counts.

cccz Follow with hansfriese

Originally disclosed on Code4rena

Submitted by cccz, also found by hansfriese

The first eight digits of the RuniverseLand TokenID indicate the corresponding plotSize of the NFT. Owner can call RuniverseLandMinter.ownerMintUsingTokenId directly to mint the NFT for a specific TokenID. In RuniverseLandMinter._mintTokensUsingTokenId, there is no verification that the first eight bits of the tokenId match the plotSize parameter, which allows the owner to bypass the plotsAvailablePerSize limit.

    function _mintTokensUsingTokenId(
        IRuniverseLand.PlotSize plotSize,
        uint256 tokenId,
        address recipient
    ) private {
        uint256 numPlots = 1;
        require(
            plotsMinted[uint256(plotSize)] <
                plotsAvailablePerSize[uint256(plotSize)],
            "All plots of that size minted"
        );
        require(
            plotsMinted[uint256(plotSize)] + numPlots <=
                plotsAvailablePerSize[uint256(plotSize)],
            "Trying to mint too many plots"
        );

        plotsMinted[uint256(plotSize)] += 1;

        runiverseLand.mintTokenId(recipient, tokenId, plotSize);
    }

For example, the plotSize parameter provided by the owner when calling ownerMintUsingTokenId is 8 * 8, while the plotSize contained in the tokenId is 128 * 128, thus bypassing the plotsAvailablePerSize limit.

Also, once RuniverseLands with mismatched tokenId and plotSize are minted, the supply of RuniverseLands with different plotSize will no longer be correct because the plotsMinted variable is incorrectly calculated.

Proof of Concept

contracts/RuniverseLandMinter.sol#L362-L393

Recommended Mitigation Steps

Consider verifying in RuniverseLandMinter._mintTokensUsingTokenId that the first eight bits of the tokenId match the plotSize parameter.

Alex the Entreprenerd (judge) commented:

Additional possibly broken invariant due to Admin Privilege.

msclecram (Forgotten Runiverse) confirmed

Alex the Entreprenerd (judge) commented:

Similarly to #11 the Warden has shown a way to bypass specific checks which offer an invariant, in this case the invariant is the fact that plotSizes are capped, which can be broken by using ownerMintUsingTokenId in an unintended way.

Because the lack of checks allows that, whereas the rest of the codebase offers checks to prevent that, I agree with Medium Severity.

msclecram (Forgotten Runiverse) commented:

We updated the code with the next changes:

  • We removed _mintTokensUsingTokenId

https://github.com/bisonic-official/plot-contract/commit/ea8abd7faffde4218232e22ba5d8402e37d96878


The original report as published on Code4rena, by cccz. 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 minting function trusts the caller-supplied plotSize parameter without validating it against the size encoded in the tokenId.

Impact

The owner could bypass the per-size minting limit and make the recorded supply of each plot size incorrect; the text does not claim any impact beyond the owner's privileged action.

What the attacker needed

Owner privileges

The fix

The code was fixed by removing the vulnerable minting function.

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.

Each land plot has a size, and the system limits how many plots of each size can be created. The owner can create plots directly, but the code never checks that the size written in the plot's ID matches the size being counted. So the owner can create a large plot while the system thinks it is a small one, breaking the limit.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by cccz

View all

104 more disclosed reports, best first.

More from Forgotten Runiverse - Versus contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.