The _burn function performs two subtraction operations in Yul assembly without underflow checks: decreasing _totalSupply and the sender's balance. Since Solidity 0.8.x's automatic underflow protection does not apply to inline assembly, an attacker can burn more tokens than available, causing integer underflow and corrupting the token's total supply and account balances.
The function uses Yul assembly for gas optimization but omits mandatory underflow checks for subtraction operations. The vulnerability occurs because the sub opcode in Yul silently wraps on underflow, unlike Solidity's checked arithmetic.
Likelihood:
Any address with burning privileges (or any user if _burn is exposed) can intentionally cause underflow by burning more tokens than the current balance or total supply.
The attack requires only a single transaction with a burn amount larger than the current balance, which is trivial to execute.
Impact:
Inflation Attack: Account balances and total supply can underflow to near-maximum values, creating an enormous amount of tokens out of thin air.
Total Supply Corruption: _totalSupply becomes mathematically incorrect, breaking all supply-dependent calculations.
Protocol-Wide Disruption: The token's economic model is destroyed, as the circulating supply can be artificially inflated to extreme values.
Result :
Ran 1 test for test/Token.t.sol:TokenTest
[PASS] test_burn_totalSupply_underflow() (gas: 62515)
Logs:
totalSupply afetr underflow: 115792089237316195423570985008687907853269984665640564039457584007913129639436
Balance Alice after underflow: 115792089237316195423570985008687907853269984665640564039457584007913129639436
Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 4.56ms (757.08µs CPU time)
Add explicit underflow checks before both subtraction operations in the _burn function
Alternative Solution: Create reusable safe arithmetic functions (e.g., safeAdd and safeSub) to avoid code duplication and ensure consistent underflow/overflow protection across the entire 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.