# Attacker Can Decide The Initialization Ratio Of The AMM Pair

Cork's AMM pool is left empty on first DS issuance, letting an attacker set the initial RA/CT ratio and drain LV depositors via arbitrage.

- Payout: Audit contest
- Severity: medium
- Program: Cork Protocol
- Found by: 0xNirix
- Disclosed: 2024-08-22
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-08-cork-protocol-judging/issues/186
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-08-cork-protocol%3AM-4
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:medium tech:evm tech:solidity technique:source-review vuln:business-logic vuln:oracle-manipulation

**Target:** UniswapV2 RA/CT AMM pool seeded by VaultLib liquidity provision
**Root cause:** onNewIssuance returns early on first DS issuance (prevDsId == 0), so the protocol never seeds the UniV2 pair; __getAmmCtPriceRatio falls back to the AMM's attacker-set ratio instead of the intended default.
**Steps:**
1. Observe first DS issuance creates the RA/CT UniV2 pair with zero liquidity.
2. Attacker deposits RA into PSM to obtain CT+DS at correct exchange rate.
3. Attacker calls UniV2 addLiquidity with tiny amounts at an arbitrary skewed ratio (e.g. 1000 RA : 100 CT).
4. Victim deposits large RA into Liquidity Vault; protocol calls __provideLiquidityWithRatio using the manipulated AMM ratio.
5. Protocol adds ~1,000,000 RA : 100,000 CT to the pool at the bad price.
6. Attacker swaps CT for RA via constant-product formula (200,000 CT -> ~666,666 RA), draining RA reserves.
**How found:** Code reading of onNewIssuance showing the early return on prevDsId == 0, combined with __getAmmCtPriceRatio's try/catch fallback that trusts the live AMM ratio, revealing the pool is empty and manipulable at first issuance.
**Exploitation:** Attacker seeds the empty pair at a skewed ratio with minimal capital, waits for LV deposits to be routed into the pool at that ratio, then arbitrages CT->RA against the constant-product curve, leaving LV holders with ~30% of expected RA on redemption.
**Escalation:** Loss propagates to all LV holders at DS expiration when _liquidatedLp returns far fewer RA, devaluing LV redemption rate (~1 RA/LV -> ~0.3 RA/LV).
**Insight:** When a protocol lazily seeds a UniV2 pair, check whether the seeding path can be skipped on first use; an empty pair plus a ratio read from that pair lets an attacker dictate the price the protocol then trusts.

