In the MembershipERC1155::mint(address to, uint256 tokenId, uint256 amount)
function, the lack of validation on the tokenId
parameter introduces a potential vulnerability. Specifically, there is no check to ensure that tokenId
falls within a valid range, leading to risks of underflow and overflow in the calculation that updates totalSupply
.
The totalSupply
variable is updated in the mint function as follows:
If tokenId
is greater than 6
, the exponent (6 - tokenId)
becomes negative. Since 2 ** (6 - tokenId)
evaluates to zero for invalid tokenId
values, this causes the result of amount * 2 ** (6 - tokenId)
to be zero. Consequently, an underflow occurs, and totalSupply
may be decremented instead of incremented, disrupting the intended total supply balance.
=>Poc
This test was done using foundry,you need foundry on your machine to run this test.
to run this test , use the command ```forge test --mt testmint`
Logs:-
** 1. Minting Failure**: If a tokenId
greater than 6
is used, totalSupply
becomes inconsistent with the actual number of tokens minted, causing the minting operation to fail.
2.DAO Limitations: This vulnerability restricts the DAO creator’s ability to mint tokens with tokenId
s above 6
, which may be critical if the contract is intended to support a broader range of token IDs.
manual review
1.Check the tokenId
in the mint()
function and revert the function call if the Id is greater than 6
.
2.since the user cannot mint tokenId
's greater than 6
, the burn_
function does not underflow but it is reccomened to check the tokenId
in the burn_
function also
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.