# Compound exchange rate can be manipulated to withdraw more underlying tokens from NotionalV3

Donating DAI to CompoundV2 cDAI inflates the cToken exchange rate, tricking Notional's prime cash oracle into overvaluing pDAI for a flash-loan profit.

- Payout: Contest reward
- Severity: medium
- Program: Notional
- Credited: mstpr-brainbot
- Disclosed: 2023-03-09
- Write-up quality: 7/10
- Original: https://github.com/sherlock-audit/2023-03-notional-judging/issues/122
- Library page: https://bugbountylibrary.com/r/sherlock%3A2023-03-notional%3AM-4
- Tags: domain:web3 impact:funds-loss kind:contest platform:sherlock sev:medium tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:flash-loan vuln:oracle-manipulation

**Target:** Notional V3 prime cash / CompoundV2 cToken adapter
**Root cause:** Prime cash underlying value derives from CompoundV2's exchange rate, which is computed as (cash+borrows-reserves)/cTokenSupply and is manipulable by donating underlying directly to the cToken contract.
**Steps:**
1. Attacker flash-loans ~4.83M DAI and deposits into Notional, receiving ~4.83M pDAI (supplyFactor assumed 1).
2. Attacker donates 50K DAI directly to the cDAI contract, raising exchange rate from 1.0 to 1.5 (150K DAI / 100K cDAI).
3. Notional recomputes currentUnderlying = 100K*1.5 + 5M = 5.15M vs lastUnderlying 5.1M, giving underlyingInterestRate 0.045.
4. supplyScalar becomes 1.045, so 4.78M pDAI now redeems for ~5M DAI.
5. Attacker withdraws pDAI for 5M DAI, repays 4.83M flash loan, keeps ~170K profit drained from Notional's idle DAI.
**How found:** Code review of PrimeCashExchangeRate/BalanceHandler showed underlying value is derived from CompoundV2's exchange rate; recognizing CompoundV2's exchange rate uses balanceOf(cToken) cash, the researcher hypothesized a donation attack and modeled the profit math.
**Exploitation:** Flash-loan large DAI, deposit to mint pDAI, donate DAI to the low-liquidity cDAI market to spike its exchange rate, then redeem pDAI at the inflated supplyFactor to extract more DAI than deposited, repaying the loan and pocketing the difference from Notional's idle balance.
**Insight:** When a protocol prices shares off a lending market's exchange rate, check whether that rate depends on token balance (donation-manipulable) rather than an internal accounting variable; low-liquidity markets make the donation cheap.
