Unchecked arithmetic in _mint allows totalSupply and balance overflow, leading to silent token supply corruption
In a standard ERC20 implementation, minting tokens increases both the recipient’s balance and the global totalSupply. These increments must revert on overflow to preserve the core invariant that the sum of all balances equals totalSupply.
In this contract, the _mint function is implemented in inline assembly and performs raw add operations when updating _totalSupply and the recipient’s balance. Because these additions are not guarded by explicit overflow checks, minting values near type(uint256).max causes arithmetic wraparound. This results in totalSupply and balances silently resetting to zero, permanently corrupting accounting invariants.
Likelihood:
This occurs whenever minting is performed with values close to type(uint256).max, which is feasible in tests, upgrades, governance actions, or misconfigured integrations.
The vulnerability is reachable in any environment where _mint is callable, including privileged roles or internal minting logic.
Impact:
totalSupply can silently wrap to zero or an arbitrary low value, breaking ERC20 supply invariants.
User balances can be reset or corrupted, enabling loss of funds, incorrect accounting, and downstream protocol failures.
The following test demonstrates that minting type(uint256).max followed by an additional mint does not revert, but instead overflows both the user balance and totalSupply.
Explanation:
The first mint sets both the user’s balance and totalSupply to the maximum uint256 value. The second mint performs add(max, 1) inside assembly, which wraps to zero instead of reverting. This confirms that overflow checks are missing and state corruption occurs silently.
Add explicit overflow checks in _mint before performing arithmetic, or delegate arithmetic to Solidity where overflow protection is enforced automatically.
_mint function:
Alternatively, remove the assembly arithmetic entirely and perform the balance and supply updates in Solidity to inherit built-in overflow 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.