Description
When a vault undergoes liquidation, its assets are set to zero, and it is considered "disposed of." However, there are two critical issues:
Unfair Share Allocation to the First Depositor
If totalShares are not reset after liquidation, the next depositor could receive an excessive number of shares.
This happens due to the conditions:
If totalAmountBefore is 0, it is artificially set to 1, leading to incorrect share calculations.
The first depositor post-liquidation ends up receiving a massively inflated share allocation.
Residual State Issues in the Vault
If key state variables such as totalShares, totalAmount, or depositInfo are not reset, they may retain stale values from the previous vault state.
This can cause incorrect accounting for future deposits and withdrawals, making the vault behave unpredictably.
If any residual funds remain post-liquidation, they could be misallocated when new deposits occur.
Impact
Unfair Advantage to Early Depositors
The first depositor post-liquidation can receive more shares than they should.
This can drastically affect reward distribution among users.
Incorrect Accounting and Possible Exploit
If vault variables are not properly reset, users may manipulate deposits to benefit from the leftover vault state.
Deposits and withdrawals could be computed incorrectly, leading to unexpected losses for some users.
Poc
Issue 1: Unfair Share Allocation
The _mint()
function contains the logic for computing share allocation:
How the Bug Occurs (Step-by-Step Reproduction)
Vault undergoes liquidation, setting assets to zero.
Key vault variables (totalShares, totalAmount) are NOT reset.
A new depositor deposits funds after liquidation.
totalAmountBefore is 0, triggering this condition:
Share calculation becomes incorrect because totalAmountBefore is artificially set to 1.
EXAMPLE Pre-Liquidation
EXAMPLE Post-Liquidation
The first depositor gets unfair shares, impacting the entire system.
ISSUE 2 -> Residual problem
If other vault variables are not reset, we face additional issues:
Residual funds might remain unaccounted for, leading to incorrect share calculations.
Future withdrawals may be miscalculated, affecting users who try to exit.
Steps for Reproduction:
Trigger liquidation to set assets to 0.
Check vault variables like totalShares, totalAmount, and depositInfo to see if they retain old values.
Deposit after liquidation and observe:
Are the calculations correct?
Is Vault still accounting for past deposits?
Recommended Mitigation
Explicitly Reset all the state variable
Ensure that after liquidation, all key variables (totalShares, totalAmount, etc.) are reset to zero to prevent incorrect calculations.
Ensure Proper Handling of Residual Funds
If any assets remain post-liquidation, properly distribute or account for them instead of ignoring them
Likelihood: Low/Medium, when fully liquidated. Liquidation often returns some tokens and shares are important to withdraw them. Moreover, shares are inflated, so only little part of tokens with huge value (WBTC) will be impacted. Impact: High, Previous depositor is able to withdraw token from the new depositors if the value of the token is huge like for WBTC.
There is no real proof, concrete root cause, specific impact, or enough details in those submissions. Examples include: "It could happen" without specifying when, "If this impossible case happens," "Unexpected behavior," etc. Make a Proof of Concept (PoC) using external functions and realistic parameters. Do not test only the internal function where you think you found something.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.