Index out of bounds error when properties length is more than attributes length breaks minting
The metadata renderer allowed the owner to add more than 15 properties, but each token can only hold 16 attributes including the property count. When a token was minted, the onMinted function tried to write past the fixed-size attribute array and reverted, blocking all future minting.
Submitted by dipp, also found by 0x1f8b, 0x52, 0xc0ffEE, 0xSky, bin2chen, datapunk, eierina, elad, hansfriese, hyh, izhuer, Jeiwan, Migue, R2, and scaraven
MetadataRenderer.sol#L188-L198
When a token is minted, the MetadataRenderer.sol onMinted function is called which will set the particular token’s attributes to a random item from one of the properties. A token has a maximum of 16 attributes, the first one being the total number of properties. The properties from which the token receives its attributes are supplied by the owner of the MetadataRenderer.sol contract by calling addProperties. The issue is that the number of properties the owner can supply is not limited. If the number of properties is more than 15 then the onMinted function will revert due to the limit on the number of attributes a token may have.
Impact
Since onMinted is always called when tokens are minted, the DAO will not be able to mint new tokens. There does not seem to be a way to remove properties so this would be unrecoverable.
Proof of Concept
Test code added to Token.t.sol:
function test_MetadataProperties() public {
createUsers(2, 1 ether);
address[] memory wallets = new address[](2);
uint256[] memory percents = new uint256[](2);
uint256[] memory vestExpirys = new uint256[](2);
uint256 pct = 50;
uint256 end = 4 weeks;
unchecked {
for (uint256 i; i < 2; ++i) {
wallets[i] = otherUsers[i];
percents[i] = pct;
vestExpirys[i] = end;
}
}
deployWithCustomFounders(wallets, percents, vestExpirys);
// Check deployed correctly
assertEq(token.totalFounders(), 2);
assertEq(token.totalFounderOwnership(), 100);
// Create 16 properties and items
string[] memory names = new string[](16);
MetadataRendererTypesV1.ItemParam[] memory items = new MetadataRendererTypesV1.ItemParam[](16);
for (uint256 j; j < 16; j++) {
names[j] = "aaa"; // Add random properties
items[j].name = "aaa"; // Add random items
items[j].propertyId = uint16(j); // Make sure all properties have items
items[j].isNewProperty = true;
}
MetadataRendererTypesV1.IPFSGroup memory group = MetadataRendererTypesV1.IPFSGroup(
"aaa",
"aaa"
); // Add random IPFS group
// Add 16 properties
vm.prank(otherUsers[0]);
metadataRenderer.addProperties(names, items, group);
// Attempt to mint
vm.prank(address(auction));
vm.expectRevert(stdError.indexOOBError);
token.mint();
}
The test code above shows that the owner of MetadataRenderer.sol is able to add 16 properties with 1 items each. The auction contract is then unable to mint due to an “Index out of bounds” error.
Code from the onMinted function in MetadataRenderer.sol:
// For each property:
for (uint256 i = 0; i < numProperties; ++i) {
// Get the number of items to choose from
uint256 numItems = properties[i].items.length;
// Use the token's seed to select an item
tokenAttributes[i + 1] = uint16(seed % numItems);
// Adjust the randomness
seed >>= 16;
}
The code above shows that when a token is minted and onMinted is called it will attempt to assign more than 16 attributes to the token which is not possible due to the tokenAttributes being limited to 16.
Recommended Mitigation Steps
The maximum amount of properties an owner can add should be less than the maximum amount of attributes any token can have. Consider either limiting the properties variable in MetadataRenderer.sol to 15 or allow any number of attributes to be added to a token.
Alex the Entreprenerd (judge) commented:
I love that you added a coded POC.
The Warden has shown how, due to a coding inconsistency, adding more than 15 properties will cause an Out-Of-Bounds error.
Because this is contingent on admin configuration, I believe Medium Severity to be appropriate.
Most direct solution is to explicitly limit the number of properties, otherwise the system could be rewritten to handle an unknown number of properties.
iainnash (Nouns Builder) confirmed
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 addProperties function did not cap the number of properties at 15, while onMinted writes one attribute per property into a fixed 16-slot array.
Impact
Minting of new tokens was permanently blocked, and since properties could not be removed the state was unrecoverable; the judge rated it Medium because it depends on admin configuration.
What the attacker needed
Owner of the metadata renderer; owner adds more than 15 properties
The fix
The number of properties should be explicitly limited to 15, or the system rewritten to handle an unknown number of properties.
How it was found
- Deploy the token with founders and the metadata renderer.
- As the metadata renderer owner, add 16 properties each with one item.
- Have the auction contract attempt to mint a token.
- Observe the mint reverts with an index out of bounds error.
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 token stores a small fixed list of attributes, and the first slot counts how many there are. The contract owner could add more properties than that list can hold, so when a new token was created the code tried to write past the end of the list and the whole mint failed. Because there was no way to remove properties, minting stayed broken.
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.