The expected behavior of _mint() is to increase an account’s balance and the global _totalSupply by the specified value, ensuring proper token creation.
In the current implementation, these increments are performed inside Yul using unchecked add() operations. Since Yul does not include Solidity’s built-in overflow protection, minting values near uint256.max causes both the account balance and total supply to overflow and wrap to zero. This breaks ERC20 accounting and allows supply corruption.
Likelihood:
Overflow occurs whenever the minted amount approaches or exceeds the uint256 limit due to raw Yul arithmetic.
The function accepts arbitrary value inputs, making this overflow easy to trigger.
Impact:
Supply corruption: _totalSupply wraps around and becomes incorrect.
Balance corruption: user balances reset to zero after overflow.
Impact Level: High
A test that first mints uint256.max tokens and then mints one more token to trigger overflow. The overflow resets the balance back to zero, confirming the issue.
Add explicit overflow checks prior to performing the arithmetic operations. If overflow is detected, revert early. Additionally, avoid using Yul for critical accounting unless necessary, as Solidity already provides safe arithmetic with built-in checks.
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.
The contest is complete and the rewards are being distributed.