# User's can create non-liquidateable positions by leveraging `rebalanceBadDebt` to decrease share price

rebalanceBadDebt cuts pool deposit assets without burning shares, letting an attacker deflate share price and inflate totalDepositShares toward uint256.max, overflowing isPositionHealthy and blocking liquidation.

- Payout: Audit contest
- Severity: medium
- Program: Sentiment
- Found by: hash
- Disclosed: 2024-08-07
- Write-up quality: 7/10
- Original: https://github.com/sherlock-audit/2024-08-sentiment-v2-judging/issues/585
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-08-sentiment-v2%3AM-23
- Tags: area:web3 domain:web3 impact:dos impact:funds-loss kind:contest platform:sherlock sev:medium tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:dos vuln:liquidation

**Target:** Lending pool contract (Pool.sol rebalanceBadDebt / RiskModule.isPositionHealthy)
**Root cause:** rebalanceBadDebt reduces pool.totalDepositAssets by the bad debt while leaving totalDepositShares unchanged, so each bad-debt event deflates share price and lets a subsequent deposit mint an outsized number of shares.
**Steps:**
1. Attacker creates a pool with `1e18` deposit assets and `1e18` shares.
2. Attacker borrows `1e18 - 1`, position goes into bad debt, `rebalanceBadDebt` is invoked: assets left = 1, shares = 1e18.
3. Attacker deposits `1e18` tokens and receives `1e36` shares due to deflated share price.
4. Repeat borrow -> bad debt -> rebalanceBadDebt cycles, each time inflating totalDepositShares further.
5. Attacker tunes deposit amounts to push totalDepositShares near `type(uint256).max`.
6. Attacker borrows from the infected pool and other target pools; accrued interest overflows fee/share math so `getBorrowsOf` and `isPositionHealthy` revert.
7. Liquidation calls revert, position becomes unliquidatable, protocol pools accrue bad debt.
**How found:** Code reading of rebalanceBadDebt noticed totalDepositAssets is decremented while totalDepositShares is untouched, implying share price deflation; reasoned that repeated bad-debt rebalances let an attacker mint exponentially more shares and eventually overflow share accounting used by getBorrowsOf/isPositionHealthy.
**Exploitation:** Attacker controls a pool's risk params (high LTV, low minDebt) so liquidators are disincentivized, waits for oracle deviation >=2% or uses zero liquidation fee, repeatedly forces own position into bad debt to trigger rebalanceBadDebt and deflate share price, inflating totalDepositShares toward uint256.max, then borrows from victim pools and lets interest overflow health checks to block liquidation.
**Escalation:** Chains share-price manipulation across multiple pools so one infected pool's overflowed state blocks isPositionHealthy for a position borrowing from other pools, spreading bad debt to unrelated depositors.
**Insight:** When a bad-debt socialization function writes down assets but not shares, check whether an attacker who controls pool risk params can repeatedly self-trigger it to inflate share supply; overflow in share/fee math can then brick health checks and block liquidation.

