Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function using msg.value called in loop #182

Open
code423n4 opened this issue Nov 17, 2021 · 1 comment
Open

Function using msg.value called in loop #182

code423n4 opened this issue Nov 17, 2021 · 1 comment
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

Comments

@code423n4
Copy link
Contributor

Handle

cmichel

Vulnerability details

The _transferInputTokens function accesses msg.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

  1. calls to _transferInputTokens in a loop always have _fromReserve == true which does not access msg.value
  2. the excess ETH still needs to already exist in the contract, which should usually not be the case as the swap amounts are either sent to the reserve or to the caller.

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 deposits msg.value to WETH once at the beginning of the swap functions makes sense.

@code423n4 code423n4 added 1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments bug Something isn't working labels Nov 17, 2021
code423n4 added a commit that referenced this issue Nov 17, 2021
@maximebrugel maximebrugel self-assigned this Nov 22, 2021
@maximebrugel
Copy link
Collaborator

We do not access msg.value in a loop expect multicall that we will remove (#226)

@maximebrugel maximebrugel added the sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons label Nov 23, 2021
@maximebrugel maximebrugel removed their assignment Nov 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

2 participants