The audit has identified unsafe ERC20 operation practices within the TokenManager.sol contract, where standard ERC20 functions are used directly without proper handling of potential failures. This is found on two specific lines of code that do not validate return values or handle possible transfer rejections adequately, thereby posing significant risks to the contract's integrity and security.
Unsafe Transfer to Sender
Location: src/core/TokenManager.sol, Line 169
Code: payable(msg.sender).transfer(claimAbleAmount);
Issue: This direct transfer method does not handle potential failures properly. If transfer fails (e.g., due to the gas limit constraints of 2300 inherent to transfer), the contract will not properly mitigate these issues, potentially leaving the contract in an inconsistent state or causing loss of funds.
Unsafe Approval Handling
Location: src/core/TokenManager.sol, Line 247
Code: ICapitalPool(\_capitalPoolAddr).approve(address(this));
Issue: The success of the approve call is not checked, which may result in assumptions that are incorrect regarding the current approval status. This can potentially lead to failed or unintended token movements which compromise the intended contract logic and security.
The identified issues can result in:
Potential loss of funds if transfers fail without being detected.
Erroneous contract behaviors due to unchecked approval statuses.
Inconsistent contract states that increase vulnerability to further exploits.
Manual Code Review
To address these issues, it is highly recommended to utilize OpenZeppelin's SafeERC20
library which ensures that ERC20 operations (transfer, approve) are safely executed and automatically handle any failure states.
Replace Direct Transfers with Safe Methods:
Use Safe Approval Methods Provided by SafeERC20
:
Invalid, known issues [Medium-2](https://github.com/Cyfrin/2024-08-tadle/issues/1)
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.