# Users might get less assets than expected upon migration due to price manipulation attacks

Attacker borrows large amount in low-liquidity BathV2 pool to skew exchangeRate, causing migrating users to receive far fewer V2 tokens than fair value.

- Payout: Contest reward
- Severity: high
- Program: Rubicon
- Credited: 0xNineDec
- Disclosed: 2025-02-17
- Write-up quality: 7/10
- Original: https://github.com/code-423n4/2023-04-rubicon-findings/issues/497
- Library page: https://bugbountylibrary.com/r/c4%3A2023-04-rubicon%3AH-14
- Tags: domain:web3 impact:funds-loss kind:contest platform:code4rena sev:high tech:evm tech:solidity technique:source-review vuln:business-logic vuln:oracle-manipulation vuln:share-inflation

**Target:** V2Migrator.migrate / BathToken V2 cToken exchange rate
**Root cause:** migrate() mints BathV2 tokens at the current exchangeRate without slippage protection; exchangeRate = (cash+borrows-reserves)/totalSupply is manipulable by large borrows/mints in a low-liquidity pool.
**Steps:**
1. Attacker obtains large capital (e.g. 10M testCoin flashloan).
2. Attacker calls `bathTokenV2.mint(initialTestBalance)` then `bathTokenV2.borrow(89% of balance)` to inflate totalBorrows and skew exchangeRate.
3. Victim calls `bathTokenV1.approve(migrator, balance)` then `migrator.migrate(bathTokenV1)`.
4. migrate() withdraws V1 underlying and calls `bathTokenV2.mint(amountWithdrawn)`, minting fewer V2 tokens due to manipulated rate.
5. Victim redeems V2 tokens and receives less underlying than fair value; attacker optionally repays borrow.
**How found:** Code review of migrate() showing mint at spot exchangeRate with no slippage check, combined with reading CToken.mintFresh/exchangeRateStoredInternal to identify manipulable inputs (totalCash, totalBorrows, totalSupply).
**Exploitation:** Precondition: low-liquidity BathV2 pool. Attacker flashloans underlying, mints V2 cTokens, borrows ~89% to inflate totalBorrows and depress exchangeRate, waits for victim migration to mint at skewed rate, then repays borrow and unwinds position, capturing the value difference from the victim's underpriced mint.
**Insight:** Any migration/wrap function that mints a cToken-style share at the live exchangeRate is manipulable via borrow/mint in the same market; check whether the mint path has slippage bounds and whether pool liquidity is thin enough to skew (cash+borrows-reserves)/totalSupply.
