# No slippage protection during repayment due to dynamic slippage params and easily influenced `slot0()`

Repay() computes swap slippage minimum from manipulable Uniswap slot0() price, so a frontrun sandwich always satisfies amountOutMinimum and steals repayer profit.

- Payout: Contest reward
- Severity: high
- Program: Real Wagmi
- Credited: 0x52
- Disclosed: 2023-10-07
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2023-10-real-wagmi-judging/issues/109
- Library page: https://bugbountylibrary.com/r/sherlock%3A2023-10-real-wagmi%3AH-4
- Tags: domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:evm tech:solidity technique:chained technique:source-review vuln:business-logic vuln:oracle-manipulation

**Target:** LiquidityBorrowingManager repay / Uniswap V3 pool slot0
**Root cause:** Repayment derives sqrtPriceX96 from Uniswap V3 slot0() and computes saleTokenAmountOut from that same spot state, then sets amountOutMinimum as a percentage of that dynamic value, so the minimum always tracks the manipulated price.
**Steps:**
1. Attacker observes victim's pending repay() tx.
2. Attacker frontruns with a large swap on the same Uniswap V3 pool (`router.exactInputSingle` with `amountOutMinimum: 0`) to move slot0 sqrtPrice.
3. Victim's repay() reads manipulated slot0(), recomputes saleTokenAmountOut, and sets amountOutMinimum relative to it.
4. Swap executes at the worse price but still passes amountOutMinimum, reducing repayer proceeds.
5. Attacker backruns to restore price and captures the difference.
**How found:** Code review of _getCurrentSqrtPriceX96 and the repay flow: noticed sqrtPriceX96 comes from slot0() (spot, manipulable) and that amountOutMinimum is computed from saleTokenAmountOut derived from that same spot value, making the slippage check tautological.
**Exploitation:** Sandwich the repay transaction: frontrun a large swap to skew slot0, let repay execute with its self-referential slippage floor, then backrun to unwind. Profit equals the price impact extracted from the repayer's swap; magnitude scales with pool liquidity (PoC shows ~8 USD loss on a deep WBTC/WETH pool).
**Insight:** When a contract computes both the expected output and the slippage floor from the same on-chain spot price (slot0/spot reserves), the check is self-referential and sandwichable; look for amountOutMinimum derived from a value the attacker can move in the same block.
