# Vault Inflation Attack

First depositor bypasses MIN_LIQUIDITY via withdraw to hold 1 wei share, then inflates share price to steal victim deposits via rounding.

- Payout: Contest reward
- Severity: medium
- Program: Flatmoney
- Credited: santipu_
- Disclosed: 2023-12-11
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2023-12-flatmoney-judging/issues/190
- Library page: https://bugbountylibrary.com/r/sherlock%3A2023-12-flatmoney%3AM-5
- Tags: domain:web3 impact:funds-loss kind:contest platform:sherlock sev:medium tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:business-logic vuln:share-inflation

**Target:** StableModule vault deposit/withdraw (ERC4626-style share accounting)
**Root cause:** MIN_LIQUIDITY check only runs after mint and can be bypassed by withdrawing down to 1 wei share; share price inflation then rounds victim deposits to zero shares.
**Steps:**
1. Attacker calls `executeDeposit` to mint 10000 wei shares (passes `totalSupply() < MIN_LIQUIDITY` check).
2. Attacker calls `executeWithdraw` to burn 9999 wei shares, leaving 1 wei share.
3. Attacker inflates assets-per-share by opening many leveraged long positions that incur losses or hit max skew 120% to pay funding to LPs, raising collateral per share.
4. Victim deposits; `_liquidityMinted = depositAmount * 10**decimals / stableCollateralPerShare` rounds down to 0 shares.
5. Attacker withdraws sole share, receiving entire vault balance including victim deposit.
**How found:** Code reading of StableModule.executeDeposit revealed MIN_LIQUIDITY check occurs post-mint and is bypassable via executeWithdraw; recognized classic ERC4626 first-depositor inflation pattern despite safeguards.
**Exploitation:** Attacker seeds 1 wei share, inflates share price via self-inflicted long losses/funding to LPs, waits for victim deposit that rounds to zero shares, then redeems sole share for full vault balance.
**Escalation:** Can also cause permanent DoS on vault by being first depositor; large victim deposits let attacker steal most funds.
**Insight:** When a minimum-liquidity guard is checked after minting rather than enforced as a permanent dead-share reserve, test whether withdraw can reduce supply below the threshold; also check whether share price can be inflated indirectly via protocol mechanics (funding/losses) when direct token transfers don't move accounting.
