# Vault is vulnerable to first depositor inflation attack

First depositor can inflate share price by directly transferring aCollateralToken to the Strategy, causing later depositors to receive fewer shares and lose funds.

- Payout: Audit contest
- Severity: high
- Program: BakerFi
- Found by: 0xStalin
- Disclosed: 2024-06-24
- Write-up quality: 7/10
- Original: https://github.com/code-423n4/2024-05-bakerfi-findings/issues/39
- Library page: https://bugbountylibrary.com/r/c4%3A2024-05-bakerfi%3AH-02
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:code4rena sev:high technique:chained vuln:accounting-error vuln:share-inflation

**Target:** Vault contract and StrategyLeverage
**Root cause:** Vault shares are not seeded at deployment, and totalAssets depends on the Strategy's aCollateralToken balance, which can be inflated by direct transfer.
**Steps:**
1. Alice deposits 10 wei ETH as first depositor, receives 10 wei shares.
2. Alice transfers 100e18 - 1 aCollateralToken directly to the Strategy, inflating totalAssets to ~100e18.
3. Bob deposits 19 ETH; shares = 19e18 * 10 / 100e18 == 10 shares (rounding down).
4. Alice redeems her 10 wei shares for ~108.1e18 aCollateralToken, stealing ~8 ETH from Bob.
**How found:** Auditor analyzed the share calculation formula and noticed that totalAssets is derived from the Strategy's aToken balance, which can be manipulated by direct transfer. They then constructed a first-depositor inflation attack scenario.
**Exploitation:** Attacker becomes first depositor with minimal ETH, then directly transfers a large amount of aCollateralToken to the Strategy to inflate the share price. Subsequent depositors receive fewer shares due to rounding, and the attacker redeems their shares for a profit, extracting value from later depositors.
**Insight:** When a vault's totalAssets depends on a token balance held by an external strategy, check if that balance can be inflated via direct transfer. First-depositor inflation attacks are still possible if shares are not seeded or virtual offsets are missing.

