MetadataRenderer contract raise error when minting
The MetadataRenderer contract allows adding properties with mismatched lengths between the names and items arrays, which causes a division by zero error when minting a token. An attacker with governance privileges could set such mismatched arrays, preventing any token from being minted and halting auctions until a new proposal fixes it.
Submitted by Migue
It is not possible to mint a ERC721 token if its properties has different length than its items.
Proof of Concept
I run the following test to reproduce the error:
deployMock();
vm.prank(address(governor));
string[] memory _names = new string[](1);
_names[0] = "propertyName"; //fill _names with some value
MetadataRendererTypesV1.ItemParam[] memory _items; //define empty array
MetadataRendererTypesV1.IPFSGroup memory _ipfsGroup;
_ipfsGroup.baseUri = "";
_ipfsGroup.extension = "";
MetadataRenderer(token.metadataRenderer()).addProperties(_names, _items, _ipfsGroup); //call add property with _items array empty.
vm.stopPrank();
vm.prank(address(auction));
uint256 success = token.mint();//error happens inside here
assert(success != 0);
vm.stopPrank();
Log from Foundry console:
├─ [736] TOKEN::metadataRenderer() [staticcall]
│ ├─ [353] Token::metadataRenderer() [delegatecall]
│ │ └─ ← METADATA_RENDERER: [0x7076fd06ec2d09d4679d9c35a8db81ace7a07ee2]
│ └─ ← METADATA_RENDERER: [0x7076fd06ec2d09d4679d9c35a8db81ace7a07ee2]
├─ [78618] METADATA_RENDERER::addProperties(["propertyName"], [], ("", ""))
│ ├─ [78172] MetadataRenderer::addProperties(["propertyName"], [], ("", "")) [delegatecall]
│ │ ├─ emit OwnerUpdated(prevOwner: FOUNDER: [0xd3562fd10840f6ba56112927f7996b7c16edfcc1], newOwner: TREASURY: [0xf8cf955543f1ce957b81c1786be64d5fc96ad7b5])
│ │ ├─ emit PropertyAdded(id: 0, name: "propertyName")
│ │ └─ ← ()
│ └─ ← ()
├─ [0] VM::stopPrank()
│ └─ ← ()
├─ [0] VM::prank(AUCTION: [0x9a1450e42d752b8731bc88f20dbaa9154642f1e6])
│ └─ ← ()
├─ [121037] TOKEN::mint()
│ ├─ [120650] Token::mint() [delegatecall]
│ │ ├─ emit Transfer(from: 0x0000000000000000000000000000000000000000, to: FOUNDER: [0xd3562fd10840f6ba56112927f7996b7c16edfcc1], tokenId: 0)
│ │ ├─ emit DelegateVotesChanged(delegate: FOUNDER: [0xd3562fd10840f6ba56112927f7996b7c16edfcc1], prevTotalVotes: 0, newTotalVotes: 1)
│ │ ├─ [25762] METADATA_RENDERER::onMinted(0)
│ │ │ ├─ [25372] MetadataRenderer::onMinted(0) [delegatecall]
│ │ │ │ └─ ← "Division or modulo by 0"
│ │ │ └─ ← "Division or modulo by 0"
│ │ └─ ← "Division or modulo by 0"
│ └─ ← "Division or modulo by 0"
└─ ← "Division or modulo by 0"
Tools Used
Foundry Manual
Recommended Mitigation Steps
It could be mitigated checking length of both arrays in MetadataRenderer.addProperties() method.
It could be done after those lines: MetadataRenderer.sol#L111-L115.
Also I recommend to move those declaration and new validation at the beginning to save gas.
iainnash (Nouns Builder) confirmed
Alex the Entreprenerd (judge) commented:
In contrast to other reports, here the Warden has shown how to get a revert by having a mismatching length between properties and items.
While a mitigating aspect for the finding is the fact that Governance will set these values, and most of the times these values will be set at deployment time. The warden has shown how the code could revert in a way that we can consider unintended.
The impact of the finding is that a new proposal would need to be raised to fix the mismatching length, until then no auctions could run.
Because of the specificity of the report, the actual DOS outcome and the reliance on “misinput”, I believe that the finding is of 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 addProperties function does not validate that the lengths of the names and items arrays match, leading to a division by zero when calculating token attributes during minting.
Impact
A mismatched configuration set by governance could cause all minting to revert, blocking auctions until a new proposal fixes the arrays.
What the attacker needed
Governance privileges to call addProperties
How it was found
- Deploy the mock contract and impersonate the governor.
- Call addProperties with a non-empty names array and an empty items array.
- Impersonate the auction contract and call mint.
- Observe the transaction revert with 'Division or modulo by 0'.
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.
This is a smart contract bug where two lists that should be the same length are not checked. When someone tries to create a new token, the code tries to divide by zero because one list is empty, which crashes the transaction. Only someone with special admin rights can set these lists, so it is not something just anyone can do.
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.