# Reward claim credited to wrong account

Claim path keyed to sender, receiver, or token list that differs from the deposit or lock owner

_Area: DeFi accounting and math bugs. Seen in 2 disclosed reports; latest 2024-07-17. Updated 2026-11-16._

## How it works
Reward and lock contracts keep per-account bookkeeping (vesting baselines, token lists, locked-token identity). The claim step must credit the same account whose bookkeeping the deposit step mutates. The assumption that breaks: that the caller (`msg.sender`) is always the beneficiary. When a deposit, mint, or lock can name a different `to`/`receiver`, or when a claim can name a different token than was locked, the two halves of the bookkeeping diverge: one account's baseline moves while another account's rewards are claimed, or a token is claimed that was never locked.

## Where it shows up
- Internal `_claim(...)` calls inside `_update`/deposit/mint paths that pass `msg.sender` while the public function takes a `to`/`receiver`.
- Baseline fields (`avgStart`, `lastUpdate`, reward-debt) written for `to` without a prior claim to `to`.
- Controller/whitelist dispatch keyed on function selector where a bool/address argument (`_claim_rewards`) selects a more permissive branch.
- Lock/claim pairs where the locked token and the claimed token are separate parameters with no cross-check.
- `tokensIn`-style arrays appended on deposit/withdraw regardless of whether rewards were actually claimed.

## How to review
For every state-mutating entry point, trace which account's bookkeeping is written and which account's rewards are settled; the invariant is: **the account whose baseline/debt is updated must be the account that was just claimed for, and the token claimed must be the token locked.** Check that `to`/`receiver` is threaded into the claim call, not `msg.sender`. For selector-based dispatch, decode the actual arguments and confirm the branch matches them. For lock/claim, confirm the claimed asset is bound to the locked asset.

## How finders spotted it
- Read `_update()`/claim path and noticed `_claim` targets `msg.sender` while deposit's `to` can differ; confirmed with a PoC asserting the `avgStart` shift and `rawClaimable` reset [E1](https://bugbountylibrary.com/r/sherlock%3A2024-07-exactly-stacking-contracts%3AM-1.md).
- Read `canCall()` dispatch, noticed overlapping signatures and that branch selection keys off signature rather than the decoded `_claim_rewards` argument [E2](https://bugbountylibrary.com/r/sherlock%3A2022-11-sentiment%3AM-2.md).
- Habit: for each internal claim, ask "sender or beneficiary?"; for each selector whitelist, ask "can defaulted args reach a looser branch?" [E1](https://bugbountylibrary.com/r/sherlock%3A2024-07-exactly-stacking-contracts%3AM-1.md)[E2](https://bugbountylibrary.com/r/sherlock%3A2022-11-sentiment%3AM-2.md).

## Variants seen
- Beneficiary mismatch: mint to `to`, claim for `msg.sender`, baseline for `to` rises unclaimed [E1](https://bugbountylibrary.com/r/sherlock%3A2024-07-exactly-stacking-contracts%3AM-1.md).
- Argument-blind dispatch: `_claim_rewards=false` still routed to the claim branch, corrupting `tokensIn` [E2](https://bugbountylibrary.com/r/sherlock%3A2022-11-sentiment%3AM-2.md).
- Token mismatch: lock one token, claim another, draining value [E3](https://bugbountylibrary.com/r/dhl%3A20230623-shido.md).

## Impact and severity
Stuck or forfeited rewards for the receiver, delayed vesting, and corrupted account accounting [E1](https://bugbountylibrary.com/r/sherlock%3A2024-07-exactly-stacking-contracts%3AM-1.md)[E2](https://bugbountylibrary.com/r/sherlock%3A2022-11-sentiment%3AM-2.md); in the lock/claim case, full value extraction (~997 WBNB via flash loan) [E3](https://bugbountylibrary.com/r/dhl%3A20230623-shido.md). Severity rises when the mismatch is reachable by anyone and the claimed asset is valuable or flash-loanable [E3](https://bugbountylibrary.com/r/dhl%3A20230623-shido.md).

## Evidence
- E1: https://bugbountylibrary.com/r/sherlock%3A2024-07-exactly-stacking-contracts%3AM-1.md
- E2: https://bugbountylibrary.com/r/sherlock%3A2022-11-sentiment%3AM-2.md
- E3: https://bugbountylibrary.com/r/dhl%3A20230623-shido.md
