# Shared pool cross-account fund drain

One account's action moves another's funds: shared lender IDs, aggregated PnL, unweighted splits, reused collateral

_Area: DeFi accounting and math bugs. Seen in 5 disclosed reports; latest 2024-07-16. Updated 2026-11-16._

## How it works
A protocol keeps one shared record (a lender address, a tick range, an aggregate margin total, a position count) and treats it as if it belonged to a single owner. When two users' positions land on that same record, the code cannot tell them apart. One user's action then reads or moves the other's funds: a withdrawal pulls the whole shared balance, a loss is subtracted from everyone's margin, an interest split ignores who contributed what, or the same collateral backs several borrows. The broken assumption is "this shared value belongs to exactly one position."

## Where it shows up
- A wrapper or manager contract that maps many users to one on-chain identity (lender address, pool, bucket) [E5](https://bugbountylibrary.com/r/sherlock%3A2023-01-ajna%3AM-22.md).
- Withdraw/transfer paths that require the full balance or read total liquidity in a range rather than per-position tracked amounts [E2](https://bugbountylibrary.com/r/c4%3A2024-05-predy%3AH-03.md)[E5](https://bugbountylibrary.com/r/sherlock%3A2023-01-ajna%3AM-22.md).
- Aggregate PnL or margin totals where one position's loss is subtracted from a shared pool [E3](https://bugbountylibrary.com/r/sherlock%3A2023-12-flatmoney%3AM-7.md).
- Fee/interest fallback branches that split equally by position count instead of weighting by amount [E4](https://bugbountylibrary.com/r/sherlock%3A2023-02-kairos%3AM-3.md).
- Pledge and borrow as separate steps, with an order ID not bound to live collateral state [E1](https://bugbountylibrary.com/r/dhl%3A20220626-xcarnival.md).

## How to review
For every shared variable, ask: can two distinct users' positions resolve to the same key? If yes, does any read or write assume sole ownership? The invariant: each user's claim on funds must be computable from their own position alone, and no operation by user A may change the balance user B can withdraw. Check that withdrawals transfer only the caller's tracked share, that losses are charged to the position or LP side that caused them, and that splits are proportional to contribution. For collateral, confirm the borrow step re-checks that the asset is still pledged and that the order ID is bound to that collateral.

## How finders spotted it
- Read the aggregate update function and noticed profit/loss was computed over total size and subtracted from a shared margin total, so one negative position propagates to all [E3](https://bugbountylibrary.com/r/sherlock%3A2023-12-flatmoney%3AM-7.md).
- Read the interest-split branch, saw division by position count rather than by amount, and built a numeric example showing dilution [E4](https://bugbountylibrary.com/r/sherlock%3A2023-02-kairos%3AM-3.md).
- Saw reallocate() read total liquidity in a tick range instead of per-pair tracked liquidity, hypothesized two pairs colliding, confirmed with a Foundry PoC [E2](https://bugbountylibrary.com/r/c4%3A2024-05-predy%3AH-03.md).
- Combined the shared-lender model with a downstream exact-balance transfer requirement, then confirmed the revert with a Foundry test [E5](https://bugbountylibrary.com/r/sherlock%3A2023-01-ajna%3AM-22.md).

## Variants seen
- Collateral reused across many borrow orders because pledge state was not re-verified [E1](https://bugbountylibrary.com/r/dhl%3A20220626-xcarnival.md).
- Liquidity ownership inferred from a shared tick range on one Uniswap pool [E2](https://bugbountylibrary.com/r/c4%3A2024-05-predy%3AH-03.md).
- Bad debt socialized into a shared margin pool [E3](https://bugbountylibrary.com/r/sherlock%3A2023-12-flatmoney%3AM-7.md).
- Equal instead of proportional interest split, gamed by padding position count [E4](https://bugbountylibrary.com/r/sherlock%3A2023-02-kairos%3AM-3.md).
- Many users mapped to one lender address, blocking partial redemption [E5](https://bugbountylibrary.com/r/sherlock%3A2023-01-ajna%3AM-22.md).

## Impact and severity
Highest where funds leave the protocol: 3087 ETH drained via repeated pledge/borrow cycles [E1](https://bugbountylibrary.com/r/dhl%3A20220626-xcarnival.md). Cross-pair accounting corruption left positions unclosable and unliquidatable [E2](https://bugbountylibrary.com/r/c4%3A2024-05-predy%3AH-03.md). Socialized bad debt zeroed solvent longs' margins and blocked withdrawals [E3](https://bugbountylibrary.com/r/sherlock%3A2023-12-flatmoney%3AM-7.md). Dilution cut legitimate lenders' yield to roughly one-ninth [E4](https://bugbountylibrary.com/r/sherlock%3A2023-02-kairos%3AM-3.md). Locked redemption stranded user funds [E5](https://bugbountylibrary.com/r/sherlock%3A2023-01-ajna%3AM-22.md). Impact scales with how many users share the record and whether the action is repeatable.

## Evidence
- E1: https://bugbountylibrary.com/r/dhl%3A20220626-xcarnival.md
- E2: https://bugbountylibrary.com/r/c4%3A2024-05-predy%3AH-03.md
- E3: https://bugbountylibrary.com/r/sherlock%3A2023-12-flatmoney%3AM-7.md
- E4: https://bugbountylibrary.com/r/sherlock%3A2023-02-kairos%3AM-3.md
- E5: https://bugbountylibrary.com/r/sherlock%3A2023-01-ajna%3AM-22.md
