Minting is not possible when a property has no items
A property with no items causes minting to revert due to a division error. An attacker could prevent minting until a new governance proposal adds an item to the property.
Submitted by Jeiwan
If a property without items was added, minting becomes impossible. To enable minting again, an item must be added to the property, which is only possible through a new governance proposal.
Proof of Concept
Consider the following test case:
function testRevert_MintingWithPropertyWithoutItems() public {
// Deploying a token and a metadata renderer
address tknImpl = address(new Token(address(this)));
Token tkn = Token(address(new ERC1967Proxy(tknImpl, "")));
address rndrImpl = address(new MetadataRenderer(address(this)));
MetadataRenderer rndr = MetadataRenderer(address(new ERC1967Proxy(rndrImpl, "")));
bytes memory initString = abi.encode("Test", "Test", "Test", "Test", "Test");
IManager.FounderParams[] memory founders = new IManager.FounderParams[](1);
founders[0] = IManager.FounderParams({ wallet: address(this), ownershipPct: 1, vestExpiry: 4 weeks });
tkn.initialize(founders, initString, address(rndr), address(this));
rndr.initialize(initString, address(tkn), address(this), address(this));
// Exploit starts here:
// Creating a property without items and adding it to the token.
string[] memory names = new string[](1);
MetadataRendererTypesV1.ItemParam[] memory items = new MetadataRendererTypesV1.ItemParam[](0);
MetadataRendererTypesV1.IPFSGroup memory ipfsGroup = MetadataRendererTypesV1.IPFSGroup({ baseUri: "base", extension: "ext" });
names[0] = "uh-oh";
// Founder forgot to add items.
rndr.addProperties(names, items, ipfsGroup);
assertEq(rndr.propertiesCount(), 1);
// Minting a token with a property without items and getting an error.
vm.expectRevert(stdError.divisionError);
tkn.mint();
// Adding an item to the property. At this point, this can only be done through a governance proposal.
names = new string[](0);
items = new MetadataRendererTypesV1.ItemParam[](1);
items[0] = MetadataRendererTypesV1.ItemParam({ propertyId: 0, name: "fixed", isNewProperty: false });
rndr.addProperties(names, items, ipfsGroup);
// Success.
tkn.mint();
assertEq(tkn.totalSupply(), 2);
}
Recommended Mitigation Steps
Short term, in the addProperties function, ensure that each newly added property has at least one item.
Long term, after adding properties and items in the addProperties function, ensure that next token can be minted and rendered without errors.
kulkarohan (Nouns Builder) acknowledged
Alex the Entreprenerd (judge) commented:
Consistently with #523, the Warden has shown how to cause
mintto revert due to handling of properties and items, in this case by having a property without any.Because this finding shows a different way to cause a revert, I will file it separately. Because it shows the same type of revert as #523, I’ll judge it in the same way as 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
Root cause
Likely, the code does not check that a property has at least one item before using the item count as a divisor, leading to a division by zero.
Impact
Minting is blocked until a governance proposal adds an item to the property, potentially causing a denial of service.
What the attacker needed
Ability to add a property without items
How it was found
- Deploy a token and a metadata renderer.
- Create a property with no items and add it to the token.
- Attempt to mint a token, which reverts with a division error.
- Add an item to the property (only possible via governance).
- Mint again, which succeeds.
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.
In this system, each token has properties, and each property should have items. If a property is added without any items, the code that picks a random item divides by zero, which crashes the minting process. This means no new tokens can be created until the property gets an item, which requires a governance vote.
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.