# Malicious actor can abuse the minimum shares check in StakingLPEth and cause DoS or locked funds for the last user that withdraws

StakingLPEth's MIN_SHARES check lets an attacker backrun deposits with 1 wei, blocking the last withdrawer's full exit and locking MIN_SHARES.

- Payout: Audit contest
- Severity: medium
- Program: LoopFi
- Found by: web3km
- Disclosed: 2025-02-17
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2024-07-loopfi-findings/issues/228
- Library page: https://bugbountylibrary.com/r/c4%3A2024-07-loopfi%3AM-10
- Tags: area:web3 domain:web3 impact:dos impact:funds-loss kind:contest platform:code4rena sev:medium tech:evm tech:solidity technique:source-review vuln:business-logic vuln:dos

**Target:** ERC4626 staking vault (StakingLPEth.sol)
**Root cause:** _checkMinShares reverts when 0 < totalSupply < MIN_SHARES on every deposit/withdraw, so a dust-share holder can keep totalSupply just above zero and block others' full withdrawals.
**Steps:**
1. User1 mints 1e18 shares via deposit.
2. Attacker backruns with a 1 wei mint, making totalSupply = 1e18 + 1.
3. User1 calls cooldown/withdraw of all shares; after super._withdraw, totalSupply = 1 < MIN_SHARES, so _checkMinShares reverts.
4. User2 deposits 1e18 shares; now User1 can withdraw.
5. Cycle repeats until the last user cannot withdraw full amount, leaving MIN_SHARES stuck.
6. DoS variant: attacker transfers 0.01 lpEth to contract pre-deposit; next depositor of 1000 lpEth gets shares = (1000e18*0+1)/(0.01e18+1) ≈ 100000 < MIN_SHARES, reverting.
**How found:** Code review of the ERC4626 _deposit/_withdraw overrides and _checkMinShares boundary condition; noticed totalSupply can be driven to exactly 1 by a dust minter, and that decimalsOffset()==0 makes the empty-vault share formula manipulable via direct transfer.
**Exploitation:** Attacker needs only 1 wei of capital to backrun each deposit, or a small direct transfer to inflate totalAssets before any shares exist, forcing reverts on legitimate users' withdraw/deposit.
**Insight:** When a vault enforces a minimum totalSupply invariant on every deposit/withdraw, check whether an attacker can park totalSupply at exactly the boundary (e.g. 1 wei) so the next legitimate full exit crosses below it and reverts; also test the empty-vault share formula with a pre-seeded donation when decimalsOffset is 0.

