# CompounderFinance: Curve strategy manipulation via flash loan

CompounderFinance's Curve strategy was manipulated via flash loan to skew yDAI pool balances, causing ~$27k loss from inflated withdrawals.

- Payout: Real-world hack
- Severity: high
- Program: CompounderFinance
- Analysis by: DeFiHackLabs
- Disclosed: 2023-06-07
- Write-up quality: 7/10
- Original: https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2023-06/CompounderFinance_exp.sol
- Library page: https://bugbountylibrary.com/r/dhl%3A20230607-compounderfinance
- Tags: area:web3 domain:web3 impact:funds-loss kind:incident platform:defihacklabs sev:high tech:evm tech:solidity vuln:accounting-error vuln:flash-loan vuln:oracle-manipulation

**Target:** Compounder DAI vault and Curve strategy contract
**Root cause:** The strategy contract's deposit function used the current pool balances to calculate shares, allowing an attacker to manipulate the yDAI/DAI exchange rate via large deposits and withdrawals.
**Steps:**
1. Flash loan 1,239,990 DAI from Uniswap V3 DAI/USDC pool.
2. Deposit 200,000 DAI into cDAI and 1,000,000 DAI into yDAI.
3. Exchange yDAI for yUSDC, yTUSD, and yUSDT on Curve to skew pool balances.
4. Transfer DAI to StrategyDAICurve, withdraw cDAI, and call StrategyDAICurve.deposit() to further manipulate.
5. Reverse the Curve exchanges to restore balances and profit from skewed rates.
6. Withdraw yDAI to receive ~1,030,000 DAI, repay flash loan, and keep profit.
**Exploitation:** Attacker used a flash loan to deposit large amounts into yDAI and cDAI, then manipulated Curve pool balances by exchanging yDAI for other stablecoins. By depositing into the strategy and then reversing exchanges, the attacker inflated the value of their yDAI shares, allowing them to withdraw more DAI than deposited, netting ~$27k profit.
**Insight:** When a strategy contract calculates share prices based on current pool balances, an attacker can use flash loans to temporarily skew those balances and profit from the resulting mispricing.

