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

n33k - LMPVaultRouterBase: Native ETH lost in router when mint&deposit #680

Closed
sherlock-admin opened this issue Aug 30, 2023 · 0 comments
Closed
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label High A valid High severity issue Reward A payout will be made for this issue

Comments

@sherlock-admin
Copy link
Contributor

sherlock-admin commented Aug 30, 2023

n33k

high

LMPVaultRouterBase: Native ETH lost in router when mint&deposit

Summary

LMPVaultRouter inherits LMPVaultRouterBase's payable mint and deposit functions. The native ETH handling logics in mint and deposit are faulty.

Vulnerability Detail

Take deposit as example. It calls _processEthIn to handle eth values in transaction.

    function deposit(
        ILMPVault vault,
        address to,
        uint256 amount,
        uint256 minSharesOut
    ) public payable virtual override returns (uint256 sharesOut) {
        // handle possible eth
        _processEthIn(vault);

        IERC20 vaultAsset = IERC20(vault.asset());
        pullToken(vaultAsset, amount, address(this));

        return _deposit(vault, to, amount, minSharesOut);
    }

_processEthIn wraps ETH to WETH. The WETH will be used for LMPVault depositing and is already in router contract.

    function _processEthIn(ILMPVault vault) internal {
        // if any eth sent, wrap it first
        if (msg.value > 0) {
            // if asset is not weth, revert
            if (address(vault.asset()) != address(weth9)) {
                revert InvalidAsset();
            }

            // wrap eth
            weth9.deposit{ value: msg.value }();
        }
    }

After _processEthIn, pullToken is called redundantly to pull WETH from user and the LMPVault is using the pulled tokens to deposit underlying. The wrapped ETH in _processEthIn is not used and will be left in router.

mint in LMPVaultRouterBase has the same problem.

Impact

Native ETH sent by user is not used for minting LMPVault shares and will be left in router contract. The left assets in router can be taken out by anyone.

Code Snippet

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

Tool used

Manual Review

Recommendation

Fix the logics in mint and deposit.

Duplicate of #1

@github-actions github-actions bot added High A valid High severity issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels Sep 11, 2023
@sherlock-admin2 sherlock-admin2 changed the title Blurry Green Yak - LMPVaultRouterBase: Native ETH lost in router when mint&deposit n33k - LMPVaultRouterBase: Native ETH lost in router when mint&deposit Oct 3, 2023
@sherlock-admin2 sherlock-admin2 added the Reward A payout will be made for this issue label Oct 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label High A valid High severity issue Reward A payout will be made for this issue
Projects
None yet
Development

No branches or pull requests

2 participants