Skip to content
DoS Audit finding Intermediate

LMPVault: DoS when `feeSink` balance hits `perWalletLimit`

The LMPVault contract enforces a per-wallet share limit, and when collecting fees it mints shares to the feeSink address. If the feeSink balance plus new fee shares exceeds the perWalletLimit, the mint reverts, causing functions that collect fees to fail.

Ch_301 Follow with n33k, warRoom and 1 other

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-06-tokemak-judging/issues/679

Found by

Ch_301, n33k, warRoom, xiaoming90

The LMPVault token share has a per-wallet limit. LMPVault collects fees as share tokens to the feeSink address. _collectFees will revert if it mints shares that make the feeSink balance hit the perWalletLimit.

Vulnerability Detail

_collectFees mints shares to feeSink.

Solidity
function _collectFees(uint256 idle, uint256 debt, uint256 totalSupply) internal {
    address sink = feeSink;
    ....
    if (fees > 0 && sink != address(0)) {
        // Calculated separate from other mints as normal share mint is round down
        shares = _convertToShares(fees, Math.Rounding.Up);
        _mint(sink, shares);
        emit Deposit(address(this), sink, fees, shares);
    }
    ....
}

_mint calls _beforeTokenTransfer internally to check if the target wallet exceeds perWalletLimit.

Solidity
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override whenNotPaused {
    ....
    if (balanceOf(to) + amount > perWalletLimit) {
        revert OverWalletLimit(to);
    }
}

_collectFees function will revert if balanceOf(feeSink) + fee shares > perWalletLimit. updateDebtReporting, rebalance and flashRebalance call _collectFees internally so they will be unfunctional.

Impact

updateDebtReporting, rebalance and flashRebalance won't be working if feeSink balance hits perWalletLimit.

Code Snippet

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

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

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

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

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

Tool used

Manual Review

Recommendation

Allow feeSink to exceeds perWalletLimit.

The original report as published on Sherlock, by Ch_301. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The per-wallet limit check in _beforeTokenTransfer applies to the feeSink address, but fee collection does not exempt feeSink from this limit.

Impact

updateDebtReporting, rebalance and flashRebalance won't be working if feeSink balance hits perWalletLimit.

What the attacker needed

FeeSink balance reaches perWalletLimit

The fix

Allow feeSink to exceed perWalletLimit.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A vault contract has a rule that no single wallet can hold more than a certain number of shares. The vault also sends fees to a special address called feeSink. When fees are collected, the vault tries to give shares to feeSink, but if that would push feeSink over the limit, the whole operation fails. This means important vault functions stop working.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by Ch_301

View all

39 more disclosed reports, best first.

More from Tokemak

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.