# Function `executeMintToTreasury` will incorrectly reduce the `supplyShares`, therefore prevent the last users  from withdrawing

executeMintToTreasury decrements totalSupply.supplyShares without burning any user's shares, breaking the supplyShares invariant and causing the last withdrawers' transactions to underflow and revert, locking funds.

- Payout: Audit contest
- Severity: high
- Program: New Scope
- Found by: 000000
- Disclosed: 2024-06-27
- Write-up quality: 7/10
- Original: https://github.com/sherlock-audit/2024-06-new-scope-judging/issues/375
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-06-new-scope%3AH-9
- Tags: area:web3 domain:web3 impact:dos impact:funds-loss kind:contest platform:sherlock sev:high tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:business-logic vuln:precision-loss

**Target:** Lending pool contract (zerolend-one) PoolLogic.executeMintToTreasury / supplyShares accounting
**Root cause:** executeMintToTreasury reduces totalSupply.supplyShares for accrued treasury shares that were never actually minted to the treasury's balance, so the invariant totalSupply.supplyShares == sum(balances.supplyShares) breaks; later withdrawals subtract user shares from an understated total and underflow.
**Steps:**
1. Accrue interest so reserve.accruedToTreasuryShares is non-zero.
2. Call executeMintToTreasury: it transfers amountToMint to treasury and does `totalSupply.supplyShares -= accruedToTreasuryShares` without touching any user balance.
3. Invariant totalSupply.supplyShares == sum(balances.supplyShares) is now violated (total is lower).
4. Users withdraw; each withdraw subtracts their supplyShares from the already-reduced total.
5. The last withdrawer's subtraction underflows and reverts, locking their funds.
**How found:** Code reading of the supplyShares invariant: noted that PositionBalanceConfiguration always updates totalSupply.supplyShares and user balances in tandem, then observed executeMintToTreasury mutates totalSupply.supplyShares alone, and reasoned the treasury shares were never credited so nothing should be burned from total.
**Exploitation:** Not an attacker-driven exploit; a logic/accounting bug triggered by normal protocol operation (interest accrual + treasury mint) that bricks the final withdrawals.
**Insight:** When auditing share-based accounting, enumerate every mutation of the global total shares and verify each is paired with a matching per-user balance change; treasury/fee mint paths are a common place where the global total is decremented without a corresponding holder balance, breaking the sum invariant and causing underflow on the last withdrawer.

