# First vault depositor can steal other's assets

First depositor front-runs victim's deposit, donates assets to inflate share price, causing victim's shares to round down to 1 and stealing ~500k.

- Payout: Contest reward
- Severity: high
- Program: Popcorn
- Credited: 0xNineDec
- Disclosed: 2023-09-07
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2023-01-popcorn-findings/issues/243
- Library page: https://bugbountylibrary.com/r/c4%3A2023-01-popcorn%3AH-10
- Tags: domain:web3 impact:funds-loss kind:contest platform:code4rena sev:high tech:evm tech:solidity technique:race-window technique:source-review vuln:accounting-error vuln:business-logic vuln:share-inflation

**Target:** ERC4626-style vault deposit/convertToShares
**Root cause:** convertToShares floors down and when supply is 1, a large donation to the adapter inflates totalAssets so the next depositor's shares round to ~1.
**Steps:**
1. Attacker `vault.deposit(1, attacker)` to mint 1 share backed by 1 asset.
2. Attacker `asset.transfer(address(vault.adapter()), 1_000_000 ether)` to inflate totalAssets to 1MM+1 with totalSupply=1.
3. Victim's `vault.deposit(2_000_000 ether, victim)` is mined; shares = 2MM/(1MM+1)*1 floors to 1.
4. Attacker `vault.redeem(1, attacker, attacker)` receives ~1.5MM, netting ~500k profit while victim loses ~500k.
**How found:** Recognized the classic ERC4626 first-depositor inflation pattern: zero-supply branch mints assets==shares, and floor rounding on convertToShares lets a donation-based share price inflation steal from the next depositor.
**Exploitation:** Front-run the victim's deposit with a 1-wei deposit plus a large direct transfer to the vault adapter, then back-run by redeeming the single share to capture half the combined pool.
**Insight:** On any vault with `supply==0 ? assets : assets*supply/totalAssets` and floor rounding, check whether an attacker can donate directly to the adapter/underlying balance to inflate totalAssets before the first real deposit; the 1-share + donation + redeem sequence is the canonical exploit.
