# Lack of slippage protection leads to loss of protocol funds

Cork Protocol's redeemEarly and _liquidateLpPartial call AMM swap/removeLiquidity with zero slippage tolerance and block.timestamp deadline, letting frontrunners sandwich protocol swaps and drain funds.

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

**Target:** VaultLib AMM swap/removeLiquidity calls (Depeg-swap contracts)
**Root cause:** swapExactTokensForTokens and removeLiquidity are invoked with minAmountOut/min amounts of 0 and deadline=block.timestamp, so no slippage or deadline protection exists on protocol-initiated AMM trades.
**Steps:**
1. Observe LV holder calls vaultLib::redeemEarly -> _liquidateLpPartial -> _redeemCtDsAndSellExcessCt
2. Note `ammRouter.swapExactTokensForTokens(ctSellAmount, 0, path, address(this), block.timestamp)` uses minOut=0
3. Note `ammRouter.removeLiquidity(raAddress, ctAddress, lp, 0, 0, address(this), block.timestamp)` uses min amounts 0
4. Frontrun the pending tx in mempool, manipulate AMM price, let protocol trade execute at manipulated price, then backrun to profit
**How found:** Manual code review of VaultLib liquidity-removal and swap paths, spotting hardcoded 0 min-amount arguments and block.timestamp deadlines in AMM router calls.
**Exploitation:** Attacker sees the protocol's redeem/liquidate tx in the mempool, sandwiches it by moving the AMM price before execution and reversing after, forcing the protocol to accept heavy slippage; a malicious node can also delay execution via block.timestamp deadline to a high-slippage moment.
**Insight:** Grep protocol contracts for AMM router calls (swapExactTokensForTokens, removeLiquidity, addLiquidity) and check that min-amount args are non-zero and deadlines are user-supplied; protocol-owned liquidity operations are prime sandwich targets.

## Proof of concept (copied exactly from the original report)

**swapExactTokensForTokens with zero slippage**

```
ra += ammRouter.swapExactTokensForTokens(ctSellAmount, 0, path, address(this), block.timestamp)[1];
```

**removeLiquidity with zero min amounts**

```
(raReceived, ctReceived) =
            ammRouter.removeLiquidity(raAddress, ctAddress, lp, 0, 0, address(this), block.timestamp);
```

