You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 3, 2024. It is now read-only.
sherlock-admin opened this issue
Aug 29, 2023
· 0 comments
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issue
ether that deposited trough _processEthIn is not considered inside router's mint and deposit operations
Summary
LMPVaultRouterBase's mint and deposit function allow users to use native eth for deposit/mint to LMPVault. However, the deposited native eth is not considered when calling pullToken. This will cause the mint and deposit functions to break if users use native eth, or worse can cause user charged more than necessary and the extra weth will stuck inside the router.
Vulnerability Detail
These are mint and deposit functions inside LMPVaultRouterBase :
function _processEthIn(ILMPVault vault) internal {
// if any eth sent, wrap it firstif (msg.value>0) {
// if asset is not weth, revertif (address(vault.asset()) !=address(weth9)) {
revertInvalidAsset();
}
// wrap eth
weth9.deposit{ value: msg.value }();
}
}
the eth provided will deposited to get weth token, this weth will be stored inside router as the caller of weth.deposit. However, inside pullToken token operations, it will try to get users funds equal to amount or assets and not considering the deposited weth :
function pullToken(IERC20token, uint256amount, addressrecipient) publicpayable {
// @audit - this will cause user to transfer more than it should if already providing eth
token.safeTransferFrom(msg.sender, recipient, amount);
}
After that, it will call _deposit also without considering the extra deposited native eth.
Impact
This could lead to 2 possible scenario :
First, user try to deposit/mint using native eth, and not have the weth balance or not previously give approval of weth to router. The operation will always revert when try to call pullToken, mint and deposit function simply broken.
The more severe impact is when user try to deposit/mint using native eth, have enough weth balance equal to amount or assets and previously given approval of weth router (give max approval for instance). The user will charged twice than expected (from native eth and his weth) and the extra weth will be stuck inside router or taken by another users that trigger _processWethOut.
The likeliness of this happening is high and potentially risking user's funds.
Fix _processEthIn so it will return value that will be considered inside pullToken function ( decrease the required weth transferred from user by the deposited native eth).
sherlock-admin2
changed the title
Rural Saffron Dinosaur - ether that deposited trough _processEthIn is not considered inside router's mint and deposit operations
saidam017 - ether that deposited trough _processEthIn is not considered inside router's mint and deposit operations
Oct 3, 2023
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issue
saidam017
high
ether that deposited trough
_processEthIn
is not considered inside router'smint
anddeposit
operationsSummary
LMPVaultRouterBase
'smint
anddeposit
function allow users to use native eth for deposit/mint to LMPVault. However, the deposited native eth is not considered when callingpullToken
. This will cause themint
anddeposit
functions to break if users use native eth, or worse can cause user charged more than necessary and the extra weth will stuck inside the router.Vulnerability Detail
These are
mint
anddeposit
functions insideLMPVaultRouterBase
:https://github.com/sherlock-audit/2023-06-tokemak/blob/main/v2-core-audit-2023-07-14/src/vault/LMPVaultRouterBase.sol#L23-L41
https://github.com/sherlock-audit/2023-06-tokemak/blob/main/v2-core-audit-2023-07-14/src/vault/LMPVaultRouterBase.sol#L44-L57
It can be observed that both functions are
payable
and will handle the deposited eth using_processEthIn
's internal function :https://github.com/sherlock-audit/2023-06-tokemak/blob/main/v2-core-audit-2023-07-14/src/vault/LMPVaultRouterBase.sol#L111-L122
the eth provided will deposited to get weth token, this weth will be stored inside router as the caller of
weth.deposit
. However, insidepullToken
token operations, it will try to get users funds equal toamount
orassets
and not considering the deposited weth :https://github.com/sherlock-audit/2023-06-tokemak/blob/main/v2-core-audit-2023-07-14/src/utils/PeripheryPayments.sol#L53-L56
After that, it will call
_deposit
also without considering the extra deposited native eth.Impact
This could lead to 2 possible scenario :
pullToken
,mint
anddeposit
function simply broken.amount
orassets
and previously given approval of weth router (give max approval for instance). The user will charged twice than expected (from native eth and his weth) and the extra weth will be stuck inside router or taken by another users that trigger_processWethOut
.The likeliness of this happening is high and potentially risking user's funds.
Code Snippet
https://github.com/sherlock-audit/2023-06-tokemak/blob/main/v2-core-audit-2023-07-14/src/vault/LMPVaultRouterBase.sol#L23-L41
https://github.com/sherlock-audit/2023-06-tokemak/blob/main/v2-core-audit-2023-07-14/src/vault/LMPVaultRouterBase.sol#L44-L57
https://github.com/sherlock-audit/2023-06-tokemak/blob/main/v2-core-audit-2023-07-14/src/vault/LMPVaultRouterBase.sol#L111-L122
Tool used
Manual Review
Recommendation
Fix
_processEthIn
so it will return value that will be considered insidepullToken
function ( decrease the required weth transferred from user by the deposited native eth).Duplicate of #1
The text was updated successfully, but these errors were encountered: