In the standard ERC20 implementation, users can set an "infinite approval amount" via approve(spender, type(uint256).max). After this, the spender can call transferFrom multiple times without needing re-approval, and the allowance value will not decrease.
However, the _spendAllowance function deducts the corresponding amount from the allowance unconditionally during each transfer. Even if the original approval value is type(uint256).max (i.e., "infinite approval"), it is treated as a regular value and decremented, thereby breaking the semantics of "infinite approval."
Likelihood:
Users frequently use the approve(spender, type(uint256).max) pattern in practice to avoid frequent approvals (especially in DEXs like Uniswap).
The contract does not handle the case where currentAllowance == type(uint256).max, causing the state to be modified with each transferFrom.
Impact:
Breaks the common usage pattern of ERC20, potentially causing abnormal behavior in third-party protocols or frontend logic that relies on "infinite approval."
Although it does not directly lead to financial loss, it increases users' gas costs (due to updating storage with each approval) and may cause user experience issues or integration compatibility risks.
Add the function test_1_spendAllowance_CantNoLimit in Token.t.sol as follows:
Input command: forge test --mt test_1_spendAllowance_CantNoLimit -vv
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.