# Unitas swap function is vulnerable to Sandwich Attack at oracle price update

Unitas swap mints/burns at oracle price; attacker sandwiches a public oracle price-update tx to buy low, sell high, draining collateral.

- Payout: Contest reward
- Severity: high
- Program: Unitasprotocol
- Credited: DevABDee
- Disclosed: 2023-04-19
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2023-04-unitasprotocol-judging/issues/67
- Library page: https://bugbountylibrary.com/r/sherlock%3A2023-04-unitasprotocol%3AH-1
- Tags: domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:evm tech:solidity technique:race-window vuln:business-logic vuln:oracle-manipulation

**Target:** Unitas.sol swap / XOracle.getLatestPrice
**Root cause:** swap() prices mint/burn solely off XOracle.getLatestPrice, and the feeder's price-update tx is publicly visible in the mempool, so the pending new price is front-runnable.
**Steps:**
1. Observe feeder tx updating USD91 oracle price from `0.012` to `0.013` in mempool
2. Front-run: `swap` 10,000 USD1 -> USD91 at old price, receiving 10,000/0.012 = 833,333.33 USD91
3. Feeder tx executes, oracle price becomes 0.013
4. Back-run: `swap` all 833,333.33 USD91 -> USD1 at new price, receiving 833,333.33*0.013 = 10,833.33 USD1
5. Redeem USD1 for USDT, extracting ~833 USD1 profit from collateral
**How found:** Code review of swap() showing price comes only from XOracle.getLatestPrice, combined with the observation that the feeder's update tx is publicly visible in the mempool before activation.
**Exploitation:** Attacker needs capital (10,000 USD1) and gas control to order txs around the public oracle update; profit is redeemed against protocol collateral.
**Insight:** When a protocol's mint/burn or swap math depends solely on an oracle value pushed by a publicly visible feeder tx, the pending update itself is the MEV surface — check whether updates are private (Flashbots) or whether trades can be ordered around them.
