In the ERC20 token's _transfer function, it is crucial to ensure the receiver's new balance does not overflow during addition operations for secure transfers.
However, this function directly uses Yul's add instruction to increase the receiver's balance without checking for potential overflow beyond type(uint256).max.
If the receiver's current balance plus the transfer amount exceeds type(uint256).max, it will cause an integer wraparound, setting the receiver's balance to an extremely small value and compromising account asset integrity.
Likelihood:
Overflows may occur when receiver balances approach type(uint256).max and receive substantial amounts
High-inflation models or specific business logic (e.g., reward distributions) increase probability
Impact:
Receiver balances may be incorrectly set to minimal values, causing fund loss and trust erosion
May trigger cascading logic failures in balance-dependent systems (staking, lending, etc.)
Compromises core token accounting integrity
Add test_1_transfer_overflow to Token.t.sol:
Execute test: forge test --mt test_1_transfer_overflow -vv
Add overflow protection before updating receiver balance:
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.