# Circle: CDP collateral manipulation drains USDC-USDs pool

Attacker manipulated a MakerDAO CDP's collateral via flash loan and Uniswap V2 exit to drain ~$50.5K from Circle's USDC-USDs pool.

- Payout: Real-world hack
- Severity: high
- Program: Circle
- Analysis by: DeFiHackLabs
- Disclosed: 2022-08-13
- Write-up quality: 6/10
- Original: https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2022-08/Circle_exp1.sol
- Library page: http://bugbountylibrary.com/r/dhl%3A20220813-circle-exp1
- Tags: area:web3 domain:web3 impact:funds-loss kind:incident platform:defihacklabs sev:high tech:evm tech:solidity vuln:business-logic vuln:flash-loan vuln:oracle-manipulation

**Target:** MakerDAO CDP and Uniswap V2 USDC-USDs pool
**Root cause:** The attacker exploited a MakerDAO CDP (id 28311) by joining DAI, then using frob to reduce collateral and debt, and flux to withdraw collateral, which was then exited from a Uniswap V2 pool to manipulate the USDC-USDs price, allowing them to sell gem (USDC) at an inflated rate.
**Steps:**
1. Flash loan 2,437,926.935218598618037988 DAI from MakerDAO.
2. Approve and join DAI into CDP 28311 via `join(urns_address, amount_dai)`.
3. Prank as attack contract and call `frob(28311, -1104761777152681125, -2419153952397280665329975)` to reduce collateral and debt.
4. Prank as attack contract and call `flux(28311, address(this), 1104761777152681125)` to withdraw collateral.
5. Call `exit(address(this), 1104761777152681125)` on Uniswap V2 to remove liquidity.
6. Transfer Uniswap V2 LP tokens and call `burn(address(this))` to redeem underlying assets.
7. Approve USDC to `allower` and call `sellGem(address(this), 1193139061611)` to sell USDC for DAI at manipulated price.
8. Repay flash loan.
**Exploitation:** The attacker used a flash loan to obtain DAI, deposited it into a MakerDAO CDP, then manipulated the CDP's collateral and debt to withdraw collateral. They exited a Uniswap V2 pool to obtain USDC and USDs, then sold USDC via MakerDAO's `sellGem` at a manipulated price, profiting ~$50.5K.
**Insight:** CDPs integrated with DEX pools can be manipulated via flash loans to distort collateral prices; check for missing slippage or oracle checks when CDP collateral is used in AMM exits.

