Skip to content
This repository has been archived by the owner on Mar 3, 2024. It is now read-only.

0xSurena - A malicious user may steal wETH balance in the LMPVaultRouter.sol #201

Closed
sherlock-admin2 opened this issue Aug 29, 2023 · 3 comments
Labels
Excluded Excluded by the judge without consulting the protocol or the senior Non-Reward This issue will not receive a payout

Comments

@sherlock-admin2
Copy link
Contributor

sherlock-admin2 commented Aug 29, 2023

0xSurena

medium

A malicious user may steal wETH balance in the LMPVaultRouter.sol

Summary

If the LMPVaultRouter contract has balance for erc20Token, a malicious user can steal it.

Vulnerability Detail

There is sweepToken function in the PeripheryPayments.sol contract. this function is using to transfer avalaible balance for erc20Token to an address. so we can assume that there is a case that erc20Token or wETH token can become available in the LMPVaultRouter contract. LMPVaultRouter is LMPVaultRouterBase.sol and this is PeripheryPayments.sol. please pay attention that sweepToken and refundETH has no access control and this is know as bug.

In the LMPVaultRouter.sol contract and withdrawToDeposit function, the _deposit function is using exact value of input amount from the user.

In the withdraw process, we know that LMPVaultRouter.sol contract cannot receive the exact amount of requested amount from DV contracts. for example if user input for amount is 10 wETH, then LMPVaultRouter.sol can receive 9.9 wETH.

But in the _deposit function, the contract is trying to use the exact 10 wETH value. Now if LMPVaultRouter contract has balance for wETH, 0.1 wETH from balance of contract will get deposit for the user.

Impact

A malicious user may steal wETH balance in the LMPVaultRouter.sol

Code Snippet

https://github.com/sherlock-audit/2023-06-tokemak/blob/main/v2-core-audit-2023-07-14/src/vault/LMPVaultRouter.sol#L31

Tool used

Manual Review

Recommendation

I Recommend to use beforeBalance and afterBalance pattern in order to deposit actual amount for user.

@github-actions github-actions bot added the Excluded Excluded by the judge without consulting the protocol or the senior label Sep 11, 2023
@sherlock-admin2
Copy link
Contributor Author

1 comment(s) were left on this issue during the judging contest.

Trumpero commented:

invalid, LMPVaultRouter is intended to hold funds

@sherlock-admin sherlock-admin changed the title Blunt Inky Yeti - A malicious user may steal wETH balance in the LMPVaultRouter.sol 0xSurena - A malicious user may steal wETH balance in the LMPVaultRouter.sol Oct 3, 2023
@sherlock-admin sherlock-admin added the Non-Reward This issue will not receive a payout label Oct 3, 2023
@0xSurena
Copy link

0xSurena commented Oct 4, 2023

Escalate

Based on the this accepted Issue, LMPVaultRouter contract can hold funds.

If the user deposits 10 ETH and approves 10 WETH to the contract, when the deposit amount is 10, all of the user's 20 WETH will be transferred into the contract. However, due to the amount being 10, only 10 WETH will be deposited into the vault, and the remaining in contract is 10 WETH.

Thanks

@sherlock-admin2
Copy link
Contributor Author

Escalate

Based on the this accepted Issue, LMPVaultRouter contract can hold funds.

If the user deposits 10 ETH and approves 10 WETH to the contract, when the deposit amount is 10, all of the user's 20 WETH will be transferred into the contract. However, due to the amount being 10, only 10 WETH will be deposited into the vault, and the remaining in contract is 10 WETH.

Thanks

The escalation could not be created because you are not exceeding the escalation threshold.

You can view the required number of additional valid issues/judging contest payouts in your Profile page,
in the Sherlock webapp.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Excluded Excluded by the judge without consulting the protocol or the senior Non-Reward This issue will not receive a payout
Projects
None yet
Development

No branches or pull requests

3 participants