# Bug in claim allows users who are disqualified to claim their previously earned emissions

ChefIncentivesController.claim checks eligibility before refreshing price data, letting users who became ineligible via price drop still claim emissions.

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

**Target:** ChefIncentivesController.sol claim function
**Root cause:** claim() calls isEligibleForRewards before checkAndProcessEligibility, which is what refreshes price/eligibility state; the stale check passes for users whose collateral value dropped below the 5% threshold.
**Steps:**
1. User stakes/locks and accrues emissions while eligible.
2. Token price drops so user's TVL falls below 5% of debt, making them ineligible.
3. User calls `claim(_user, _tokens)`; `isEligibleForRewards` returns true on stale data.
4. `checkAndProcessEligibility(_user, true, true)` runs after and refreshes state, but claim proceeds and `_vestTokens` pays out pending emissions.
**How found:** Code reading of claim() ordering: noticed isEligibleForRewards lacks refresh while checkAndProcessEligibility includes it, so the guard runs on outdated state.
**Exploitation:** Ineligible user (or anyone calling claim for them) triggers claim before eligibility refresh, extracting previously earned emissions despite disqualification.
**Insight:** When a guard reads cached eligibility and a later call refreshes it, check ordering: any refresh-triggering call placed after the guard means the guard validates stale state.

