Dria

Swan
NFTHardhat
21,000 USDC
View results
Submission Details
Severity: low
Invalid

Inadequate transfer method on LLMOracleCoordinator::withdrawPlatformFees function

Summary

The LLMOracleCoordinator::withdrawPlatformFees function is intended to transfer platform fees accumulated in the contract to the owner. At present, it employs the standard ERC-20 transfer function. To enhance security and ensure proper verification of the transfer, it’s advised to replace transfer with safeTransfer from OpenZeppelin's SafeERC20 library. This adjustment would address potential compatibility issues with tokens that exhibit unconventional behavior during transfers.

Vulnerability Details

The transfer function is used to transfer the platform fees to the owner. However, using transfer directly may not handle all ERC-20 token implementations correctly, as some tokens do not return true on a successful transfer or may revert under certain conditions. This can lead to a failed transfer, causing platform fees to be potentially locked in the contract.

function withdrawPlatformFees() public onlyOwner {
feeToken.transfer(owner(), feeToken.balanceOf(address(this))); // @audit use safetransfer() instead of transfer
}

Impact

Using transferinstead of safeTransfer

  1. If the token does not conform strictly to the ERC-20 standard, the transfer function may not work as expected, potentially leading to a failed transfer and preventing the withdrawal of platform fees.

  2. In cases where the transfer fails without proper handling, platform fees could be locked in the contract, impacting the owner's ability to access these funds.

Tools Used

Manuel Review

Recommendations

To enhance security and ensure compatibility with various ERC-20 tokens, it is recommended to use the safeTransfer function provided by OpenZeppelin's SafeERC20 library.

//Import SafeERC20 Library:
+ import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
// Update function code
+ using SafeERC20 for IERC20;
+ function withdrawPlatformFees() public onlyOwner {
+ feeToken.safeTransfer(owner(), feeToken.balanceOf(address(this)));
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 12 months ago
Submission Judgement Published
Invalidated
Reason: Known issue
Assigned finding tags:

[KNOWN] - Low-35 Unsafe use of transfer()/transferFrom() with IERC20

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.