# An attacker can manipulate the preDepositvePrice to steal from other users

First staker in SafEth shrinks totalSupply to 1 wei and donates derivative tokens, inflating preDepositPrice so later stakers mint 0 safETH and lose deposits.

- Payout: Contest reward
- Severity: high
- Program: Asymmetry Finance
- Credited: monrel
- Disclosed: 2023-07-28
- Write-up quality: 7/10
- Original: https://github.com/code-423n4/2023-03-asymmetry-findings/issues/1098
- Library page: https://bugbountylibrary.com/r/c4%3A2023-03-asymmetry%3AH-01
- Tags: domain:web3 impact:funds-loss kind:contest platform:code4rena sev:high tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:share-inflation

**Target:** SafEth staking contract (Solidity)
**Root cause:** preDepositPrice derives from live derivative balances divided by totalSupply; first depositor can shrink totalSupply to 1 wei and inflate underlyingValue by donating derivative tokens, so mintAmount rounds to 0 for later stakers.
**Steps:**
1. Attacker stakes 100 ETH as first depositor; totalSupply initialized to 1e18.
2. Attacker unstakes all but 1 wei of safETH, leaving totalSupply = 1.
3. Attacker transfers derivative tokens (e.g. 10 wstETH) directly to the WstEth derivative contract, inflating underlyingValue.
4. Victim stakes 1.5 ETH; preDepositPrice is huge so `mintAmount = totalStakeValueEth * 1e18 / preDepositPrice` rounds down to 0.
5. Attacker holds all safETH and withdraws 100% of pooled deposits.
**How found:** Code reading of stake() initialization: noticed totalSupply==0 branch sets price to 1e18 but nothing prevents first depositor from immediately unstaking to 1 wei, and underlyingValue reads live derivative balances that anyone can donate to.
**Exploitation:** Attacker needs to be first staker with enough capital to seed the pool, then unstake down to 1 wei and donate derivative tokens to inflate share price; victim deposits mint zero shares, attacker redeems entire pool.
**Insight:** In vault/share contracts, check whether the first-depositor price uses live token balances (donatable) rather than internal accounting, and whether totalSupply can be driven to 1 wei before a victim deposit.
