# Malicious actors can front-run setYieldConvEnabled

Enabling yieldConvEnabled sharply raises _totalAssets; an attacker front-runs the owner's tx with a deposit to capture unearned share of accumulated rewards.

- Payout: Audit contest
- Severity: medium
- Program: Peapods Finance
- Found by: pashap9990
- Disclosed: 2025-01-08
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2025-01-peapods-finance-judging/issues/313
- Library page: https://bugbountylibrary.com/r/sherlock%3A2025-01-peapods-finance%3AM-15
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:medium tech:evm tech:solidity technique:race-window vuln:accounting-error vuln:business-logic vuln:reward-distribution

**Target:** AutoCompoundingPodLp vault contract (Solidity)
**Root cause:** When yieldConvEnabled is false, _processRewardsToPodLp returns early and _totalAssets is not updated despite reward tokens sitting in the contract; flipping the flag to true causes _totalAssets to jump sharply on the next processing.
**Steps:**
1. Reward tokens accumulate in AutoCompoundingPodLp while yieldConvEnabled=false; _totalAssets excludes them.
2. Owner submits setYieldConvEnabled(true) tx.
3. Attacker sees tx in mempool and front-runs with deposit(), receiving shares priced against the stale (lower) _totalAssets.
4. Owner tx executes; _processRewardsToPodLp converts rewards and adds _lpAmtOut to _totalAssets.
5. Attacker withdraws, capturing a share of the newly recognized rewards they did not earn.
**How found:** Code reading of _processRewardsToPodLp: noticed the early return on !yieldConvEnabled skips the _totalAssets += _lpAmtOut update, so enabling the flag retroactively inflates share value — a classic deposit-before-value-jump front-run.
**Exploitation:** Mempool observation of the owner's setYieldConvEnabled(true) transaction; attacker deposits just before it lands at the pre-conversion share price, then withdraws after _totalAssets is bumped by reward conversion, pocketing a proportional slice of other users' profit.
**Insight:** When a config flag gates whether accrued value is recognized in _totalAssets, the flip itself is a value-changing event; check whether deposits/withdrawals are priced against stale accounting during the transition window.

