Function using msg.value
called in loop
#182
Labels
1 (Low Risk)
Assets are not at risk. State handling, function incorrect as to spec, issues with comments
bug
Something isn't working
sponsor acknowledged
Technically the issue is correct, but we're not going to resolve it for XYZ reasons
Handle
cmichel
Vulnerability details
The
_transferInputTokens
function accessesmsg.value
if the input token is ETH, and this function is called in a loop in_submitOutOrders
.Therefore, in theory, one can specify two ETH orders but only pay once as the
msg.value
will be processed in each order iteration.Impact
The severity is low as
_transferInputTokens
in a loop always have_fromReserve == true
which does not accessmsg.value
Recommended Mitigation Steps
I'd advocate against using
msg.value
in a loop.Imo, the best way to circumvent this is to not deal with ETH in the contract at all and just use WETH directly, as that's what the contract wants anyway for the orders.
Maybe just adding a
depositAllETH
function that depositsmsg.value
to WETH once at the beginning of the swap functions makes sense.The text was updated successfully, but these errors were encountered: