Summary
The approve
function in the CapitPool
contract fails to account for some tokens (like USDT) that don't conform to the standard return value pattern or require resetting allowance to zero before updating. This oversight can lead to failed approvals for certain tokens. and its doesnt use safeTransfer/safeTransferFrom in the transfer functions
The current implementation assumes all ERC20 tokens behave in a standard way:
This implementation has two main issues:
It doesn't handle tokens that don't return a boolean value on approval (e.g., USDT).
It doesn't reset the allowance to zero before setting a new value, which some tokens (like USDT) require.
Example Scenario:
A user attempts to call the approve
function for a USDT token.
Since USDT does not return a boolean value, the success
check might not detect a failed approval.
The approval call might also revert if the current allowance is not set to 0 before being updated.
As a result, the transaction fails, preventing the user from creating pairs with USDT.
Inability to use popular stablecoins like USDT, limiting the contract's functionality and user base.
Manual code Review
To mitigate this vulnerability, consider implementing the following changes:
Use OpenZeppelin's SafeERC20
library for all ERC20 interactions for approve and transfer /. This library handles non-standard tokens gracefully
Implement a token whitelist to ensure only properly vetted tokens can be used with the contract.
Invalid, low level call will always return true as long as the call succeeds without reverting, so this has no impact described, given approvals can only fail when some weird tokens do not allow a uint256.max approval, which is not described in any of the issues below.
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.