# The attacker can steal rewards from AutoCompoundingPodLP because in _processRewardsToPodLp, the rewards from TokenRewards are not distributed

AutoCompoundingPodLp compounds rewards without first distributing TokenRewards, letting an attacker deposit and redeem in one tx to skim pending rewards.

- 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/233
- Library page: https://bugbountylibrary.com/r/sherlock%3A2025-01-peapods-finance%3AM-7
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:medium tech:evm tech:solidity technique:chained technique:source-review vuln:accounting-error vuln:business-logic vuln:reward-distribution

**Target:** AutoCompoundingPodLp._processRewardsToPodLp / TokenRewards
**Root cause:** _processRewardsToPodLp converts reward tokens to spTKN without calling distribute first; rewards only distribute when spTKN is transferred (setShares), so pending rewards get compounded after the attacker's deposit and are shared with them.
**Steps:**
1. Ensure TokenRewards holds undistributed rewards for AutoCompoundingPodLp and aspTKN has no reward-token balance.
2. Attacker bonds PEAS and adds liquidity to obtain spTKN.
3. In one tx: `_aspTKN1Peas.deposit(950e18, bob)` — spTKN transfer triggers setShares/distribute, pulling rewards into aspTKN uncompounded.
4. Same tx: `_aspTKN1Peas.redeem(950e18, bob, bob)` — _processRewardsToPodLp compounds rewards into spTKN, attacker redeems share.
5. Attacker ends with more spTKN than deposited, diluting existing stakers.
**How found:** Code reading of _processRewardsToPodLp noticing no distribute() call, then tracing that distribution only happens via setShares on spTKN transfer, and that _tokenToPodLp is skipped when balances are zero.
**Exploitation:** Single-transaction deposit+redeem sandwich around the lazy reward distribution: deposit spTKN to trigger distribute, then redeem to compound and capture a pro-rata share of rewards not intended for the attacker.
**Insight:** In ERC4626-style autocompounders, check whether pending external rewards are distributed before share accounting; if distribution is triggered lazily by token transfer, a deposit+redeem in one tx can capture rewards accrued before deposit.

