# Use of slot0 to get sqrtPriceLimitX96 can lead to price manipulation.

RootBridgeAgent reads Uniswap V3 slot0 spot price to set sqrtPriceLimitX96 for gas swaps, letting a sandwicher skew the price and drain value from the swap.

- Payout: Contest reward
- Severity: high
- Program: Maia DAO Ecosystem
- Credited: shealtielanz
- Disclosed: 2023-09-18
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2023-05-maia-findings/issues/823
- Library page: https://bugbountylibrary.com/r/c4%3A2023-05-maia%3AH-02
- Tags: domain:web3 impact:funds-loss kind:contest platform:code4rena sev:high tech:evm tech:solidity technique:chained technique:source-review vuln:business-logic vuln:oracle-manipulation

**Target:** RootBridgeAgent.sol gas swap functions (_gasSwapIn/_gasSwapOut) using Uniswap V3 pool
**Root cause:** sqrtPriceX96 is read from Uniswap V3 slot0, the manipulable latest tick/price, and used to compute sqrtPriceLimitX96 for the swap instead of a manipulation-resistant TWAP.
**Steps:**
1. Attacker observes pending _gasSwapIn/_gasSwapOut tx calling IUniswapV3Pool.swap with sqrtPriceLimitX96 derived from slot0.
2. Front-run: swap heavily in the pool to move slot0 sqrtPriceX96 in the attacker's favor.
3. Victim tx executes, computing sqrtPriceLimitX96 from the manipulated slot0 and swapping at the skewed price.
4. Back-run: attacker reverses their pool position, capturing the price difference at the victim's expense.
**How found:** Code review of RootBridgeAgent gas swap functions noting sqrtPriceX96 sourced from slot0 (spot) rather than TWAP, a known manipulation vector.
**Exploitation:** Sandwich attack via MEV bot/flash loan: manipulate slot0 price before the bridge agent's gas swap, let it execute at the distorted limit, then unwind for profit; victim swap suffers loss of funds.
**Insight:** When a contract derives a swap price limit from slot0, the limit itself becomes attacker-controlled input; check every slot0 read that feeds swap parameters, not just oracle pricing.
