secondaryMinter may break plotsAvailablePerSize
The RuniverseLand contract allows both primaryMinter and secondaryMinter to mint NFTs, but only the RuniverseLandMinter contract enforces per-size plot limits. The secondaryMinter can mint any tokenId without those limits, breaking the plotsAvailablePerSize invariant.
Submitted by cccz
RuniverseLand allows primaryMinter and secondaryMinter to mint NFT.
function mintTokenId(
address recipient,
uint256 tokenId,
PlotSize size
) public override nonReentrant {
require(numMinted < MAX_SUPPLY, "All land has been minted");
require(
_msgSender() == primaryMinter || _msgSender() == secondaryMinter,
"Not a minter"
);
numMinted += 1;
emit LandMinted(recipient, tokenId, size);
_mint(recipient, tokenId);
}
RuniverseLandMinter, as one of them, will have a limit on the number of NFTs with different PlotSize
uint256[] public plotsAvailablePerSize = [
52500, // 8x8
16828, // 16x16
560, // 32x32
105, // 64x64
7 // 128x128
];
This will be checked in _mintTokens
function _mintTokens(
IRuniverseLand.PlotSize plotSize,
uint256 numPlots,
address recipient
) private {
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"
);
for (uint256 i = 0; i < numPlots; i++) {
uint256 tokenId = ownerGetNextTokenId(plotSize);
plotsMinted[uint256(plotSize)] += 1;
But the other minter is not limited and can mint RuniverseLand with any tokenID, thus breaking the plotsAvailablePerSize limit.
Proof of Concept
contracts/RuniverseLand.sol#L88-L102 contracts/RuniverseLandMinter.sol#L323-L341
Recommended Mitigation Steps
Consider making RuniverseLandMinter the only minter for RuniverseLand.
Alex the Entreprenerd (judge) commented:
Risk of broken invariant, will flag, unsure about severity.
msclecram (Forgotten Runiverse) acknowledged
Alex the Entreprenerd (judge) commented:
The warden has shown a way to bypass specific checks, while the function is privileged, the lack of checks is inconsistent with the checks applied in other parts of the codebase.
For this reason, I agree with Medium Severity.
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
Impact
The secondaryMinter could mint land NFTs without respecting the per-size limits, breaking the intended scarcity invariant.
What the attacker needed
SecondaryMinter privileges
The fix
RuniverseLandMinter should be the only minter for RuniverseLand, or the secondaryMinter should also enforce the same limits.
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 has two special accounts allowed to create new land NFTs. One of them is supposed to enforce a cap on how many plots of each size exist, but the other account can create plots freely, bypassing that cap. This means the promised scarcity of each plot size can be violated.
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.