# Price calculation susceptible to flashloan exploits

USSDRebalancer reads Uniswap slot0 spot price instead of TWAP, letting an attacker flash-loan-manipulate USSD price and trigger profitable rebalance draining collateral.

- Payout: Contest reward
- Severity: high
- Program: USSD
- Credited: 0xHati
- Disclosed: 2023-05-15
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2023-05-USSD-judging/issues/451
- Library page: https://bugbountylibrary.com/r/sherlock%3A2023-05-USSD%3AH-5
- Tags: domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:evm tech:solidity technique:source-review vuln:flash-loan vuln:oracle-manipulation

**Target:** USSDRebalancer.sol rebalance price oracle (Uniswap DAI-USSD pool)
**Root cause:** Rebalancer derives USSD price from Uniswap slot0 instantaneous reserves ratio rather than a TWAP, so the price is manipulable within a single transaction.
**Steps:**
1. Take a flash loan of DAI/USSD.
2. Swap in the DAI-USSD Uniswap pool to skew slot0 price read by USSDRebalancer (lines 71-80).
3. Call rebalance() while price is skewed.
4. Provide JIT liquidity to pools rebalance interacts with and arbitrage the mispriced swaps.
5. Repay flash loan, keep profit; collateral drained from contract.
**How found:** Code review of USSDRebalancer price fetch; noticed it reads Uniswap slot0 spot price instead of TWAP, a known manipulation vector.
**Exploitation:** Attacker flash-loans capital, manipulates the DAI-USSD pool slot0 ratio, triggers rebalance which trades at the manipulated price, and captures the difference via JIT liquidity/arbitrage against the pools rebalance touches, draining collateral.
**Insight:** When auditing rebalancers/oracles, grep for slot0/spot reserve reads and check whether any state-changing function trades on that price within the same tx; spot price + same-tx action = flash-loan manipulable.
