# Loan-inflated aggregate manipulation

Prices or incentives from pool averages, TVL weights, or user-supplied fields one position can skew

_Area: DeFi oracles, liquidations and flash loans. Seen in 6 disclosed reports; latest 2024-09-03. Updated 2026-10-23._

## How it works
A protocol derives a price, incentive, or settlement value from an aggregate: average debt per loan (debt/loanCount), TVL-weighted pool price, a moving average of reserves, or a user-supplied price field. The assumption is that these aggregates reflect many independent actors and move slowly, so reading them is safe. A single large position — often opened and closed atomically with a flash loan — shifts the aggregate enough to change the value read at the moment a payout, liquidation, or settlement is evaluated. The attacker need not hold the position; the aggregate only has to be wrong when consumed.

## Where it shows up
- Pricing or incentive parameters divided by loan count or total debt (average debt size) [E5](https://bugbountylibrary.com/r/sherlock%3A2023-01-ajna%3AM-10.md)
- Oracle weighting pools by TVL computed from current spot reserves [E6](https://bugbountylibrary.com/r/c4%3A2021-12-vader%3AM-06.md)
- Settlement/PnL formulas using a user-supplied price field not bounded against the oracle [E1](https://bugbountylibrary.com/r/sherlock%3A2024-08-perennial-v2-update-3%3AH-4.md)
- Liquidation price derived from debt/collateral ratio with no oracle cap [E3](https://bugbountylibrary.com/r/c4%3A2024-07-benddao%3AM-13.md)
- Manipulation deterrents gated by a per-call threshold rather than aggregate size (adjacent) [E4](https://bugbountylibrary.com/r/sherlock%3A2023-02-gmx%3AM-27.md)
- Averages refreshed by a privileged EOA rather than read at consumption (adjacent staleness) [E7](https://bugbountylibrary.com/r/c4%3A2021-11-malt%3AM-30.md)

## How to review
For each aggregate, ask: can one actor move it within a single transaction, and does any payout, liquidation, or settlement decision read it? The invariant: the value used for pricing or incentives must not be changeable by a position the attacker can open and close atomically. Check that TVL weights use time-weighted or cumulative reserves, not spot [E6](https://bugbountylibrary.com/r/c4%3A2021-12-vader%3AM-06.md); that averages are computed at the consumption point or from cumulative accumulators [E7](https://bugbountylibrary.com/r/c4%3A2021-11-malt%3AM-30.md); that user-supplied price fields are bounded against the oracle and collateral references that same price [E1](https://bugbountylibrary.com/r/sherlock%3A2024-08-perennial-v2-update-3%3AH-4.md); that liquidation prices are capped by an oracle [E3](https://bugbountylibrary.com/r/c4%3A2024-07-benddao%3AM-13.md); and that thresholds key off aggregate size, not per-call size [E4](https://bugbountylibrary.com/r/sherlock%3A2023-02-gmx%3AM-27.md). Trace every consumer of a manipulable value and confirm a bad read cannot still trigger a payout.

## Variants seen
- Frontrun kickAuction with a large loan to inflate average pool debt, lowering MOMP/NP so kickers are penalized [E5](https://bugbountylibrary.com/r/sherlock%3A2023-01-ajna%3AM-10.md)
- Flash-loan skew reserves so one pool dominates a TVL-weighted oracle [E6](https://bugbountylibrary.com/r/c4%3A2021-12-vader%3AM-06.md)
- Unbounded user-supplied settlement price mints PnL collateral from a tiny deposit [E1](https://bugbountylibrary.com/r/sherlock%3A2024-08-perennial-v2-update-3%3AH-4.md)
- Uncapped debt/collateral-derived liquidation price blocks liquidation after a crash [E3](https://bugbountylibrary.com/r/c4%3A2024-07-benddao%3AM-13.md)
- Per-order threshold bypassed by splitting into sub-threshold orders [E4](https://bugbountylibrary.com/r/sherlock%3A2023-02-gmx%3AM-27.md)
- Stale EOA-refreshed averages farmed repeatedly via stabilize [E7](https://bugbountylibrary.com/r/c4%3A2021-11-malt%3AM-30.md)

## Impact and severity
Griefing of liquidators/kickers [E5](https://bugbountylibrary.com/r/sherlock%3A2023-01-ajna%3AM-10.md), oracle price distortion [E6](https://bugbountylibrary.com/r/c4%3A2021-12-vader%3AM-06.md), fund theft via inflated settlement [E1](https://bugbountylibrary.com/r/sherlock%3A2024-08-perennial-v2-update-3%3AH-4.md), bad debt from skipped liquidations [E3](https://bugbountylibrary.com/r/c4%3A2024-07-benddao%3AM-13.md), and reward farming [E7](https://bugbountylibrary.com/r/c4%3A2021-11-malt%3AM-30.md). Severity rises when the manipulated value gates liquidation incentives or settlement payouts, when a single pair can dominate pricing, and when the position can be unwound in the same transaction.

## Evidence
- E1: https://bugbountylibrary.com/r/sherlock%3A2024-08-perennial-v2-update-3%3AH-4.md
- E2: https://bugbountylibrary.com/r/c4%3A2026-01-olas%3AH-02.md
- E3: https://bugbountylibrary.com/r/c4%3A2024-07-benddao%3AM-13.md
- E4: https://bugbountylibrary.com/r/sherlock%3A2023-02-gmx%3AM-27.md
- E5: https://bugbountylibrary.com/r/sherlock%3A2023-01-ajna%3AM-10.md
- E6: https://bugbountylibrary.com/r/c4%3A2021-12-vader%3AM-06.md
- E7: https://bugbountylibrary.com/r/c4%3A2021-11-malt%3AM-30.md
