# forceUnsponsor() may open a window for attackers to manipulate the _totalShares and freeze users' funds at a certain deposit amount

forceUnsponsor drains totalUnderlying to zero, letting an attacker inflate _totalShares via 1 wei deposit and freeze user funds.

- Payout: Audit contest
- Severity: high
- Program: Sandclock
- Found by: WatchPug
- Disclosed: 2022-02-23
- Write-up quality: 7/10
- Original: https://github.com/code-423n4/2022-01-sandclock-findings/issues/168
- Library page: https://bugbountylibrary.com/r/c4%3A2022-01-sandclock%3AH-01
- Tags: domain:web3 impact:dos 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:** Vault.sol forceUnsponsor/deposit share accounting
**Root cause:** forceUnsponsor transfers totalUnderlying() even when sponsorAmount exceeds it, leaving _totalUnderlyingMinusSponsored at 0/1 wei; deposit share math then divides by near-zero, inflating newShares massively.
**Steps:**
1. Call `forceUnsponsor()` with sponsorAmount > totalUnderlying() so contract transfers all underlying out, leaving ~0 balance.
2. Attacker sends `1 wei` underlying to the Vault.
3. Call `deposit(0.1 * 1e18)`; `newShares = (_amount * _totalShares) / _totalUnderlyingMinusSponsored` with denominator 1 yields extremely large newShares.
4. totalShares becomes precisely manipulated; subsequent deposit/withdraw at certain amounts reverts, freezing funds.
**How found:** Code review of forceUnsponsor's branch logic: noticed the `_force && sponsorAmount > totalUnderlying()` path transfers totalUnderlying() unconditionally, leaving the denominator in the deposit share formula near zero.
**Exploitation:** Attacker empties Vault via forceUnsponsor, seeds 1 wei, then deposits a small amount to mint an enormous share count, planting a 'bomb' that bricks deposit/withdraw at specific amounts and freezes other users' funds.
**Escalation:** Chains with the share-manipulation bomb from issue #166 but does not rely on reentrancy, so the reentrancy fix does not mitigate it.
**Insight:** Audit forced-exit/emergency paths that bypass normal balance checks: any function that can drive the vault's underlying balance to ~0 while totalShares > 0 enables first-depositor share inflation without needing a flash loan.
