Similar to transfer, an ERC20 burn operation must prevent user balances from going below 0, since subtracting more than the current balance will underflow and wrap to type(uint256).max.
In ERC20Internals::_burn, the contract subtracts value from the user’s balance in inline assembly without checking that value <= accountBalance. Because inline assembly uses unchecked arithmetic, the balance can underflow and wrap to type(uint256).max.
Likelihood:
Underflow occurs whenever _burn is called with an amount greater than the user’s balance. Because _burn does not enforce this check, any misuse by an inheriting contract or future extension can immediately trigger the issue.
Impact:
This breaks the ERC20 accounting, causing incorrect pricing and share accounting. An underflow in a user's balance will inflate the token balance to type(uint256).max, which could enable protocol This breaks ERC20 accounting, causing incorrect pricing, share accounting, and governance weight. An underflow in a user’s balance inflates it to type(uint256).max, which can enable manipulation of any protocol that accepts the token.
Add the following test to the test suite in test/Token.t.sol.
This test shows that the token balance of user2 underflowed to type(uint256).max after a burn when user2 had a balance of 0.
Make sure to replace revert(0, 0) with a custom error to align with the rest of the error handling in the contract.
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.