The refund
function in the contract lacks proper access control, allowing any user, regardless of whether they have deposited assets or not, to call the function and trigger refund processes. This can lead to unintended behavior and potential abuse. Adding a proper validation check for deposited assets before processing refunds is necessary to secure the function.
The current implementation of the refund
function does not verify whether the caller has deposited any assets before allowing the refund process. As a result, users who have not deposited any assets can still call the function, leading to redundant operations and unnecessary state changes. The code snippet below illustrates the issue:
This lack of a proper condition to validate the presence of refundable assets can allow abuse and affect the contract's efficiency and gas usage.
Unnecessary operations for users with no refundable assets.
Potential confusion among users when calling the refund function without prior deposits.
Increased gas costs due to redundant operations.
Manual code review.
Introduce a validation check in the refund
function to ensure that the caller has refundable assets before processing the refund. The following code snippet demonstrates the corrected implementation:
balances[_to][i_USDC] == 0
: Checks if the user has no USDC balance.
balances[_to][i_WBTC] == 0
: Checks if the user has no WBTC balance.
balances[_to][i_WETH] == 0
: Checks if the user has no WETH balance.
etherBalance[_to] == 0
: Checks if the user has no ETH balance.
If all these conditions are true, the function will revert with the message "No Assets to Refund."
Add a validation check to ensure the caller has refundable assets.
Use a comprehensive condition to check all supported asset balances.
Revert the transaction if the user has no refundable assets to prevent unnecessary operations.
Implementing these recommendations will enhance the function's security and operational efficiency.
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.