In the MembershipERC1155
contract, a public function called MembershipERC1155::uri
allows anyone to retrieve the URI for any token ID. The protocol has a limited token supply with IDs ranging from 0 to 6, but if a user attempts to retrieve the URI for tokenId = 7
, they can still obtain a response. To enhance security, it would be beneficial to enforce a maximum token ID check and, potentially, restrict URI retrieval access to only authorized minters.
MembershipERC1155::uri
:
The following Foundry test demonstrates this vulnerability. Follow these steps to set up and run the test:
Convert the project to a Foundry-based structure.
Install all required dependencies.
Configure necessary remappings.
Create a file called MembershipERC1155Test.sol
within the test
folder.
Add the following code in MembershipERC1155Test.sol
:
Create a mock
folder in the test
directory.
Add CurrencyMock.sol
and OWPWalletMock.sol
within this folder, and implement the mock contracts as needed.
Open a terminal and execute the following command to run the test:
Review the test results:
As shown, the uri
function returns a URI even for a nonexistent token ID, which could mislead users.
Potential for user misinterpretation.
Unintentional behavior due to lack of token ID validation.
Manual Review, Foundry
Implement a check to prevent URI retrieval for tokenId > 6
. Example:
If restricting access to authorized minters is intended, consider the following:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.