The approve function in the LibTokenApprove library has a vulnerability where setting an allowance to type(uint256).max can lead to unrestricted and unchecked token transfers.
The root cause of the issue is that the approve function allows setting the allowance to type(uint256).max. This effectively grants the spender infinite approval to transfer tokens on behalf of the owner, bypassing the need for future allowance updates and potentially leading to unchecked token transfers.
Consider this scenario
1: Alice approves Bob to spend an infinite amount of tokens (by setting the allowance to type(uint256).max).
2: Bod can now transfer an unlimited number of tokens from Alice's account without any further approval.
3: Alice has no control over the transfers as the allowance remains effectively infinite
1: This wil lead to unchecked and potentially unauthorized token transfers, as the spender can continuously transfer tokens without the owner being able to intervene or limit the transfers.
2: The token owner will find it difficult to regain control over their tokens, leading to potential misuse and loss of assets
Manual Review
1: Implement a pattern where the current allowance is set to zero before updating it to a new value. This can prevent the spender from exploiting the allowance update process.
2: Prevent setting the allowance to type(uint256).max or any excessively large value.
3: Use functions like increaseAllowance and decreaseAllowance to adjust allowances incrementally, reducing the risk of setting overly large allowances.
Modified approveToken Function
Modified LibTokenApprove.approve Function
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.