The unchecked return values of the call()
method in the UTBExecutor
contract pose a potential risk of fund lock or incomplete operations in swapAndExecute
or bridgeAndExecute
.
#526
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-25
insufficient quality report
This report is not of sufficient quality
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/code-423n4/2024-01-decent/blob/011f62059f3a0b1f3577c8ccd1140f0cf3e7bb29/src/UTBExecutor.sol#L54
https://github.com/code-423n4/2024-01-decent/blob/011f62059f3a0b1f3577c8ccd1140f0cf3e7bb29/src/UTBExecutor.sol#L67
https://github.com/code-423n4/2024-01-decent/blob/011f62059f3a0b1f3577c8ccd1140f0cf3e7bb29/src/UTBExecutor.sol#L70
Vulnerability details
swapAndExecute
andbridgeAndExecute
are two pivotal functions in the Decent protocol, outlined in theUTB
contract. Both functions invoke theexecute()
function within theUTBExecutor
contract through the_swapAndExecute
function of theUTB
contract. This call is integral to the execution of a payment transaction involving native and/or ERC20 tokens.And the Issue is, the
execute()
function within theUTBExecutor
contract contains several external calls to atarget
contract and ETH transfer torefund
address without proper checks for the return values. This can lead to two critical issues: funds may become stuck due to a failed refund, and the failure of the payment execution call may go unnoticed, potentially resulting in incomplete operations or loss of funds.Impact
The impact of this finding is twofold:
Funds Stuck Due to Failure of Refund: If the call to the
target
contract fails, the contract attempts to refund the native currency to therefund
address. Without checking the success of this refund, funds could be permanently locked in the contract, leading to a direct financial loss for users.Incomplete Operation or Loss of Funds: The lack of checks after calling
target.call(payload)
means that if the call fails, the contract does not revert the transaction. This could result in the ERC20 tokens being locked or lost, and the intended operation not being executed, which is misleading and potentially damaging to users.This vulnerability permits the
UTB
contract to perform a currency swap from the incoming to the outgoing token and initiate a transaction involving payment. However, it occurs without actually executing the proper payment or refund and without carrying out the execution of functions within the target contract.Proof of Concept
The
execute()
function within theUTBExecutor
does not check the return value of therefund.call{value: amount}("")
orrefund.call{value: extraNative}("")
, which can lead to funds being stuck in the contract.The contract does not check the return value of
target.call(payload)
, which can lead to an incomplete operation or loss of funds.The following code snippets from the
UTBExecutor
contract demonstrate the issues:https://github.com/code-423n4/2024-01-decent/blob/011f62059f3a0b1f3577c8ccd1140f0cf3e7bb29/src/UTBExecutor.sol#L52C12-L56C20
https://github.com/code-423n4/2024-01-decent/blob/011f62059f3a0b1f3577c8ccd1140f0cf3e7bb29/src/UTBExecutor.sol#L66C13-L68C14
https://github.com/code-423n4/2024-01-decent/blob/011f62059f3a0b1f3577c8ccd1140f0cf3e7bb29/src/UTBExecutor.sol#L70
Tools Used
Manual Review
Recommended Mitigation Steps
To mitigate these issues, the following steps are recommended:
Implement checks for the return value of the refund calls and revert the transaction if the refund fails. This ensures that either the operation succeeds, or the funds are safely returned to the user.
Implement checks for the return value of the payment execution call and revert the transaction if the call fails. This ensures that the operation either completes successfully or is entirely rolled back, preventing any loss of funds.
Example fixes for the issues are as follows:
For unchecked refund:
Implementing these checks will significantly improve the contract's reliability and safeguard users' funds against potential losses due to failed transactions.
Assessed type
Invalid Validation
The text was updated successfully, but these errors were encountered: