# Making _totalSupply and _totalShares imbalance significantly by providing fake income leads to stealing fund

Attacker donates stETH to inflate excess income, skewing _totalSupply vs _totalShares so redemptions burn zero shares and drain other users' collateral.

- Payout: Contest reward
- Severity: high
- Program: Lybra Finance
- Credited: HE1M
- Disclosed: 2023-08-21
- Write-up quality: 8/10
- Original: https://github.com/code-423n4/2023-06-lybra-findings/issues/340
- Library page: https://bugbountylibrary.com/r/c4%3A2023-06-lybra%3AH-05
- Tags: domain:web3 impact:funds-loss kind:contest platform:code4rena sev:high tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:business-logic vuln:share-inflation

**Target:** LybraStETHVault / EUSD share accounting
**Root cause:** excessIncomeDistribution mints/burns shares using getSharesByMintedEUSD which rounds to zero when _totalSupply >> _totalShares; direct stETH donation creates fake income that skews the ratio.
**Steps:**
1. Day 0: Bob deposits 1 ETH, mints 200e18+1 eUSD -> shares=200e18+1, _totalSupply=200e18+1, _totalShares=200e18+1
2. Bob transfers 0.2 stETH directly to vault, then calls `excessIncomeDistribution(2e17)`; payAmount=200e18 eUSD, sharesAmount=200e18 burned, Bob receives 0.2 stETH back
3. State now: _totalSupply=200e18+1, _totalShares=1
4. Alice deposits 10 ETH, mints 4000e18 eUSD -> gets only 19 shares (4000e18*1/(200e18+1))
5. Bob repeatedly calls `rigidRedemption(Alice, eusdAmount)` with eusdAmount ~ _totalSupply/_totalShares; getSharesByMintedEUSD rounds to 0 so no shares burned but stETH paid out
6. Repeat ~60 times to extract ~4 stETH from Alice's collateral; also steal protocol income via excessIncomeDistribution with 0-share burn
**How found:** Code reading of excessIncomeDistribution and getSharesByMintedEUSD rounding; noticed direct stETH donation counts as excess income and that share math truncates to zero when _totalSupply >> _totalShares.
**Exploitation:** Attacker seeds vault at launch with minimal deposit, donates stETH to create fake excess income, buys it back via excessIncomeDistribution burning nearly all shares, leaving _totalSupply huge vs _totalShares=1. Subsequent depositors receive near-zero shares. Attacker then calls rigidRedemption/liquidation repeatedly with amounts where shares round to zero, receiving stETH without burning shares, draining other users' collateral and protocol income.
**Escalation:** Attack repeatable: after repaying borrow in small increments to re-skew ratio, attacker can re-inflate and hit each new depositor; also affects liquidation and EUSD transfers (dust transfers revert).
**Insight:** In share-based lending vaults, any path that lets an attacker inflate totalAssets/totalSupply ratio (direct donation counted as income) combined with integer-division share minting enables zero-share redemptions; check rounding direction on getSharesByMintedEUSD and whether donations are excluded from income accounting.
