Project

One World
NFTDeFi
15,000 USDC
View results
Submission Details
Severity: low
Invalid

Lack of Validation for amount Parameter in Mint Function

Summary

The mint function lacks a validation check to ensure that the amount parameter is greater than zero. This oversight allows for the potential minting of zero tokens

https://github.com/Cyfrin/2024-11-one-world/blob/1e872c7ab393c380010a507398d4b4caca1ae32b/contracts/dao/tokens/MembershipERC1155.sol#L60

function test_mint() public {
console2.log("Total Supply Before: ", mERC1155.totalSupply());
mERC1155.mint(msg.sender, 0, 0);
console2.log("Total Supply after: ", mERC1155.totalSupply());
}
Ran 1 test for test/Foundry/TestMembershipERC1155.t.sol:TestMembershipERC1155
[PASS] test_mint() (gas: 42857)
Logs:
Total Supply Before: 0
Total Supply after: 0

Impact

Even its not affect the total supply still, the function will execute operations and emit events unnecessarily, leading to:

  • Wasted gas on zero-value mint operations, impacting efficiency.

  • Minor vulnerabilities in the integrity of event logs due to redundant entries.

Tools Used

Manual review

Recommendations

Add amount Validation: Include a require statement at the beginning of the function to ensure that amount is greater than zero:

solidity
require(amount > 0, "Amount must be greater than zero");
Updates

Lead Judging Commences

0xbrivan2 Lead Judge 12 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
0xbrivan2 Lead Judge 12 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.