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.
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.
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.
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
Tool used
Manual Review
Recommendation
Allow feeSink to exceeds perWalletLimit.
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.