UTBExecutor.sol#execute() - The target
address can gas bomb/return bomb users, forcing them to pay massive amounts of gas.
#70
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
edited-by-warden
primary issue
Highest quality submission among a set of duplicates
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
sufficient quality report
This report is 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/07ef78215e3d246d47a410651906287c6acec3ef/src/UTBExecutor.sol#L52
https://github.com/code-423n4/2024-01-decent/blob/07ef78215e3d246d47a410651906287c6acec3ef/src/UTBExecutor.sol#L65
https://github.com/code-423n4/2024-01-decent/blob/07ef78215e3d246d47a410651906287c6acec3ef/src/UTBExecutor.sol#L70
Vulnerability details
Impact
The
UTBExecutor
contract implements aexecute
function, which makes an arbitrary call to a target address with a payload, and with or without a value.You'll notice that every time
target
is called, we use(success, )
.This is the same as writing
(bool success, bytes memory data)
.success
meaning if the tx reverted or not and thedata
being what the function returned, if anything.In the current code
data
is omitted, but because of the waycall
works, any data that the function returns will still be copied into memory.Memory allocation is very costly, and the
target
might return a massive amount of data, either maliciously or not, and the user will be forced to pay a huge amount of gas for copying it into memory, even though the return data isn't used anywhere in theexecute
function.Proof of Concept
swapAndExecute
.UTB
performs the swap through Uniswap and forwards the call toexecute
insideUTBExecutor
.target
address'fallback
function gets triggered and he returns a huge amount of data.target
gas griefed Alice.Tools Used
Manual Review
Recommended Mitigation Steps
Use a low-level assembly calls and do not copy the return data to memory.
Calculating the gas cost will also negate a 63/64 attack.
Assessed type
call/delegatecall
The text was updated successfully, but these errors were encountered: