Description:
The internal _burn implementation in ERC20Internals performs unchecked subtraction on both totalSupply and the account balance, without verifying that the account has enough tokens or that totalSupply is large enough. It uses raw Yul sub without any underflow checks:
Any caller can therefore burn an arbitrary value from any account, even if that account’s balance (and global totalSupply) is much smaller than value. Because the subtractions are unchecked, they underflow and wrap modulo 2^256, effectively creating enormous balances and totalSupply values.
Impact:
A malicious user can:
Underflow another user’s balance, turning a small balance into 2^256 - 1 tokens.
Underflow totalSupply, breaking all supply‑based invariants and likely any DeFi integrations relying on it.
If the token is used in DeFi protocols (AMMs, lending, gauges), this can be used to:
Drain pools by transferring the artificially inflated balance.
Break assumptions about totalSupply (e.g. share price calculations, reward distributions), potentially leading to further downstream loss of funds.
Even if a specific derived token intends to restrict access to _burn, the base implementation is unsafe “by default” and is therefore very easy to misuse (as demonstrated by the sample Token).
Overall this is critical when _burn is exposed directly or indirectly to untrusted users, and still high‑risk even when only “trusted” code calls it, because a single missing check in future extensions leads to catastrophic consequences.
Proof of Concept:
Token using Token-0x ERC20:
Token2 using OpenZeppelin ERC20:
Running these tests shows:
Token-0x Token does not revert and instead sets both balanceOf(alice) and totalSupply() to 2^256 - 1.
OpenZeppelin’s Token2 correctly reverts the transaction.
Mitigation:
Add explicit checks in _burn before performing the subtractions:
Alternatively, implement _burn in Solidity with default checked arithmetic and only use assembly for storage slot derivation.
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.