Unchecked arithmetic in _burn allows balance and totalSupply underflow, causing wraparound to maximum values
In a correct ERC20 implementation, burning tokens must decrease both the account balance and the global totalSupply. If the burn amount exceeds either the account balance or the total supply, the operation must revert to prevent underflow and preserve accounting invariants.
In this contract, _burn is implemented in inline assembly and uses raw sub operations to decrease totalSupply and the account balance. These subtractions are performed without any underflow checks. When value is greater than the current balance or supply, the subtraction wraps around to type(uint256).max, silently corrupting state.
Likelihood:
This occurs whenever _burn is called with a value larger than the account balance or current totalSupply, which is possible through misuse, faulty integrations, or logic errors in higher-level burn functions.
Any internal or privileged path that invokes _burn without strict pre-validation exposes this vulnerability.
Impact:
totalSupply can underflow to type(uint256).max, permanently breaking ERC20 supply invariants.
User balances can wrap to type(uint256).max, effectively granting unlimited tokens and enabling severe accounting and economic exploits.
The following test demonstrates that burning more tokens than the user owns does not revert, but instead causes both the user balance and totalSupply to underflow and wrap to type(uint256).max.
Explanation:
The user is minted 10 tokens. Burning 11 tokens triggers sub(10, 11) inside assembly for both balance and totalSupply. Since no underflow check exists, the result wraps to 2^256 - 1, leaving the contract in a severely corrupted state.
Add explicit underflow checks in _burn to ensure that both the account balance and total supply are sufficient before performing subtraction, or rely on Solidity’s checked arithmetic.
_burn function:
Alternatively, move balance and supply updates out of assembly and into Solidity to automatically enforce underflow protection.
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.