ERC20Internals::_spendAllowance function always subtracts from allowance even when it is type(uint256).max, breaking infinite allowance semantics and causing unexpected reverts or logic failures in integrations.In ERC20 implementations like OpenZeppelin, if allowance is set to type(uint256).max, it is treated as infinite and is not reduced when transferFrom is called.
In this implementation, _spendAllowance always subtracts the spent value, even when the allowance is at its maximum, removing the semantics of infinite allowance.
Likelihood: Medium
This manifests whenever an integration uses type(uint256).max assuming infinite allowance.
Repeated calls to transferFrom reduce the allowance and eventually cause unexpected reverts.
Impact: Low
Does not put funds at risk, but breaks the usual infinite allowance semantics used by many ERC20 integrations.
Can cause logic failures in protocols that rely on this standard behavior.
This test validates that, even when setting an allowance to type(uint256).max, the _spendAllowance function reduces it after a transferFrom, showing that the implementation does not maintain the infinite allowance semantics typical of OpenZeppelin and may break integrations expecting this behavior.
Preserve the standard ERC20 semantics for infinite allowances by updating the allowance only when it is not type(uint256).max, aligning behavior with OpenZeppelin and preventing unwanted consumption of an unlimited allowance.
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.