# Users of a vault can steal other user's rewards when one vault's lastRewardTime differs from another vault's lastRewardTime

Per-pool lastRewardTime divergence in ChefIncentivesController lets a pool with stale timestamp over-claim availableRewards, stealing another pool's reward share.

- Payout: Audit contest
- Severity: medium
- Program: LoopFi
- Found by: rscodes
- Disclosed: 2025-02-17
- Write-up quality: 7/10
- Original: https://github.com/code-423n4/2024-07-loopfi-findings/issues/158
- Library page: https://bugbountylibrary.com/r/c4%3A2024-07-loopfi%3AM-22
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:code4rena sev:medium tech:solidity technique:source-review vuln:accounting-error vuln:reward-distribution

**Target:** ChefIncentivesController reward accounting (Solidity)
**Root cause:** _newRewards caps rawReward by the global availableRewards() (depositedRewards - accountedRewards) rather than the calling pool's own remaining allocation, so a pool whose lastRewardTime lags others can consume rewards already earmarked for pools that updated later.
**Steps:**
1. Deploy two pools with equal allocPoint and deposit 120 ether rewards, rewardsPerSecond=1 ether.
2. Alice borrows in vault1, Bob borrows in vault2 (both handleActionAfter at t=0).
3. At t=1min Alice changes debt by 1 wei in vault1, triggering _updatePool only for pool1 (accountedRewards += part A).
4. At t=3min (past endRewardTime) Alice calls claim -> _updatePool -> _newRewards: duration = z - x, rawReward capped to availableRewards() = B+C.
5. Alice receives ~75 ether, Bob only ~45 ether; 15 ether stolen.
**How found:** Noticed _newRewards uses global availableRewards() while lastRewardTime is per-pool; reasoned that pools updated at different times would double-count the same available rewards, then built a Foundry PoC with two equal pools to confirm the imbalance.
**Exploitation:** Any user of a vault can trigger a trivial debt change to advance only their pool's lastRewardTime, then claim after endRewardTime so their pool's rawReward is capped by the global availableRewards() that still includes other pools' unaccounted share, extracting a fraction of their rewards.
**Insight:** When reward accounting mixes a global 'available' pool balance with per-pool timestamps, check whether a lagging pool can consume rewards already reserved for pools that checkpointed earlier; construct two equal-weight pools with staggered update times to expose the double-count.

