Losses are not distributed equally
The withdrawal mechanism allows users to burn shares from profitable destination vaults first, so faster users can exit with minimal loss while slower users bear a larger share of losses from depreciating vaults. An attacker could monitor vault performance and withdraw quickly to avoid losses, leaving remaining users with a faster rate of depreciation.
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2023-06-tokemak-judging/issues/591
Found by
xiaoming90
The losses are not distributed equally, leading to slower users suffering significant losses.
Vulnerability Detail
Assume that three (3) destination vaults (DVs) and the withdrawal queue are arranged in this order: $DV_A$, $DV_B$, $DV_C$.
Assume the following appreciation and depreciation of the price of the underlying LP tokens of the DV:
- Underlying LP Tokens of $DV_A$ appreciate 5% every T period (Vault in Profit)
- Underlying LP Tokens of $DV_B$ depreciate 5% every T period (Vault in Loss)
- Underlying LP Tokens of $DB_C$ depreciate 10% every T period (Vault in Loss)
For simplicity's sake, all three (3) DVs have the same debt value.
In the current design, if someone withdraws the assets, they can burn as many $DV_A$ shares as needed since $DV_A$ is in profit. If $DV_A$ manages to satisfy the withdrawal amount, the loop will stop here. If not, it will move to $DV_B$ and $DB_C$ to withdraw the remaining amount.
However, malicious users (also faster users) can abuse this design. Once they notice that LP tokens of $DV_B$ and $DV_C$ are depreciating, they could quickly withdraw as many shares as possible from the $DV_A$ to minimize their loss. As shown in the chart below, once they withdrew all the assets in $DV_A$ at $T14$, the rest of the vault users would suffer a much faster rate of depreciation (~6%).
Thus, the loss of the LMPVault is not evenly distributed across all participants. The faster actors will incur less or no loss, while slower users suffer a more significant higher loss.
Impact
The losses are not distributed equally, leading to slower users suffering significant losses.
Code Snippet
Tool used
Manual Review
Recommendation
Consider burning the shares proportionately across all the DVs during user withdrawal so that loss will be distributed equally among all users regardless of the withdrawal timing.
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 withdrawal logic burns shares from destination vaults in a fixed order, starting with profitable ones, rather than proportionally across all vaults, allowing users to selectively exit from the best-performing assets.
Impact
Slower users suffer a significantly higher loss because faster users can withdraw from profitable vaults first, leaving the depreciating assets for the rest.
What the attacker needed
A vault with multiple destination vaults; some vaults in profit, others in loss; ability to withdraw quickly
The fix
The withdrawal logic should burn shares proportionately across all destination vaults so that losses are shared equally regardless of withdrawal timing.
How it was found
- Observe that some destination vaults are depreciating while others are in profit.
- Withdraw assets quickly, burning shares from the profitable vault first.
- If the profitable vault satisfies the withdrawal, the loop stops and the user avoids losses.
- Remaining users are left with depreciating vaults and suffer a higher loss rate.
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.
This is a decentralised finance (DeFi) vault where users deposit funds that are spread across several underlying investments. When someone withdraws, the system takes money from the best-performing investments first. This means people who withdraw early can take the good assets, leaving the bad ones for everyone else, so later users lose more money.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.