# Attacker can steal rewards in AutoCompoundingPodLp because he can revert the compounding with slippage

Attacker manipulates swap slippage to revert reward compounding in AutoCompoundingPodLp, deposits, then redeems to capture rewards meant for prior depositors.

- Payout: Audit contest
- Severity: medium
- Program: Peapods Finance
- Found by: Schnilch
- Disclosed: 2025-01-08
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2025-01-peapods-finance-judging/issues/274
- Library page: https://bugbountylibrary.com/r/sherlock%3A2025-01-peapods-finance%3AM-9
- 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 vuln:reward-distribution

**Target:** AutoCompoundingPodLp reward compounding swap (_pairedLpTokenToPodLp)
**Root cause:** Reward compounding swap enforces a 5% oracle-based slippage bound; an attacker can push pool price to exceed it and revert compounding, leaving rewards un-compounded in the contract. New depositors then share in those rewards on the next successful compound.
**Steps:**
1. Ensure podOracle set and LEAVE_AS_PAIRED_LP true (or paired LP in _allRewardsTokens).
2. Rewards sit in AutoCompoundingPodLp awaiting compounding.
3. Attacker swaps paired LP token -> pTKN via V2 router to skew pool price beyond 5% slippage.
4. Attacker deposits spTKN into AutoCompoundingPodLp; compounding swap reverts, rewards stay uncompounded.
5. Attacker swaps pTKN back to paired LP to restore price.
6. Attacker redeems; compounding now succeeds, inflating spTKN per share, attacker withdraws more spTKN than deposited.
**How found:** Code review of _pairedLpTokenToPodLp swap: noticed the 5% slippage minimum can be forced to fail by an external swap, and that failed compounding leaves rewards in-contract to be captured by new depositors.
**Exploitation:** Attacker with spTKN skews the pTKN/paired-LP pool via a V2 swap so the oracle-bounded compounding swap reverts, deposits spTKN while rewards are stuck, restores price, then redeems after compounding to capture a share of rewards belonging to earlier depositors.
**Insight:** When a compounding/harvest swap enforces a tight oracle-based slippage bound, an attacker can grief it to revert and then enter/exit around the failed harvest to dilute rewards; check whether failed harvests leave value in-contract and whether deposit/redeem share accounting captures it.

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

**Command to run the PoC**

```
forge test --mt testPoc -vv --fork-url <FORK_URL>
```

