# NXUSD: flash-loan LP oracle manipulation drains CauldronV2 market

NXUSD CauldronV2 on Avalanche used a manipulable LP-token oracle; attacker flash-loaned USDC, pumped the LP price, borrowed NXUSD against inflated collateral, and drained the market.

- Payout: Real-world hack
- Severity: critical
- Program: NXUSD
- Analysis by: DeFiHackLabs
- Disclosed: 2022-09-06
- Write-up quality: 7/10
- Original: https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2022-09/NXUSD_exp.sol
- Library page: https://bugbountylibrary.com/r/dhl%3A20220906-nxusd
- Tags: area:web3 domain:web3 impact:funds-loss kind:incident platform:defihacklabs sev:critical tech:evm tech:solidity technique:chained vuln:flash-loan vuln:oracle-manipulation

**Target:** CauldronV2 lending market on Avalanche using DegenBox and a Uniswap V2 LP-token exchange-rate oracle
**Root cause:** CauldronV2.updateExchangeRate derived collateral value from a spot Uniswap V2 LP token price that could be moved within a single transaction, so a flash-loan-funded swap inflated the collateral value used for borrowing.
**Steps:**
1. Flash-loan `51_000_000_000_000` USDC from Aave.
2. Buy WAVAX with USDC and add liquidity to the USDC/WAVAX Pair (`0xf4003F4efBE8691B60249E6afbD307aBE7758adb`) to acquire LP tokens.
3. Swap remaining USDC for WAVAX to push the Pair price and inflate the LP token value.
4. Approve DegenBox and call `setMasterContractApproval(address(this), masterContract, true, 0, 0, 0)`.
5. Call `CauldronV2.updateExchangeRate()` to refresh the manipulated rate.
6. Call `CauldronV2.cook([5,21,20,10], [0,0,0,0], datas)` with borrow `998_000 * 1e18`, withdraw NXUSD, deposit the inflated LP as collateral, and enter market.
7. Sell received WAVAX, swap NXUSD through Curve metaPool to USDC_e, then USDC_e to USDC, and repay the Aave flash loan.
**Exploitation:** The attacker flash-borrowed 51M USDC, used part to buy WAVAX and mint USDC/WAVAX LP tokens, then swapped the rest to spike the Pair price. The inflated LP value let them borrow 998,000 NXUSD against it via CauldronV2.cook. They sold the WAVAX, converted NXUSD to USDC through Curve pools, and repaid the flash loan, keeping the profit.
**Insight:** When a lending market prices LP tokens from a Uniswap V2 pair's spot reserves, a single flash-loan swap can inflate collateral enough to borrow the entire market; check whether updateExchangeRate reads manipulable spot state rather than a TWAP.

