UTBExecutor does not revert in case refund transfer fails, leading to tokens stuck #179
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-25
edited-by-warden
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/main/src/UTBExecutor.sol#L52-L56
Vulnerability details
Impact
Proof of Concept
If a user call function
UTB.swapAndExecute
then in the last step, the contract will callUTBExecutor.execute
and this function is currently implemented as:As you can see, if user specify
tokenOut == address(0)
(native tokens), then the functionexecute
will try to calltarget.call
, if not successful, then callrefund.call{value: amount}
. However, the refund call will not revert in case it fails, for example ifrefund
is a smart contract withoutfallback
function, causing the tokens to get stuck inUTBExecutor
and not refunded to user.The correct behavior here is to either revert if
refund.call
is not successful, or transfer the wrapped token instead to refund address.Below is a POC for the above issue, save it to a file named
test/UTBFeeCollectorRefundNotRevert.t.sol
and run it using command:forge test --match-path test/UTBFeeCollectorRefundNotRevert.t.sol --match-test testFeeCollectorRefundNotRevert -vvvv
You can see in the log that both function
VeryCoolCat::mintWithUsdc
(thetarget
) andDummyContract::fallback
(therefund
) revert but the swap is still successful and native tokens get stuck inUTBExecutor
.Tools Used
Manual Review
Recommended Mitigation Steps
I recommend either reverting if
refund.call
fails or transferring wrapped native tokens torefund
instead.Assessed type
ETH-Transfer
The text was updated successfully, but these errors were encountered: