# RedeemQueue Accounting Mismatch Between Batch Creation and Claim Eligibility

RedeemQueue's _handleReport excludes the last pre-report redemption via latestEligibleIndex--, but claim() allows it, letting a later user drain an earlier batch and lock others' shares.

- Payout: Audit contest
- Severity: high
- Program: Mellow Flexible Vaults
- Found by: 7
- Disclosed: 2025-07-12
- Write-up quality: 8/10
- Original: https://github.com/sherlock-audit/2025-07-mellow-flexible-vaults-judging/issues/65
- Library page: https://bugbountylibrary.com/r/sherlock%3A2025-07-mellow-flexible-vaults%3AH-2
- Tags: area:web3 domain:web3 impact:dos impact:funds-loss kind:contest platform:sherlock sev:high tech:solidity technique:source-review vuln:accounting-error vuln:business-logic

**Target:** RedeemQueue.sol batch accounting / claim eligibility
**Root cause:** _handleReport uses upperLookupRecent(timestamp) then decrements latestEligibleIndex, excluding the last request before the report timestamp from the batch, while claim() accepts any timestamp <= latestEligibleTimestamp from prices, so a request outside the batch can still claim from it.
**Steps:**
1. Deploy vault with DepositQueue and RedeemQueue; users deposit and claim to get shares.
2. user1 redeems at t0, user2 at t0+100, user3 at t0+200 (each 10,000,000 shares).
3. Call `redeemQue.handleReport(1e18, t0+150)` as vault.
4. Observe `batchAt(0)` shares == only user1's amount (user2 excluded by latestEligibleIndex--).
5. Call `redeemQue.handleBatches(2)` to move assets.
6. user2 calls `claim(user2, [t0+100])` and succeeds, draining batch 0.
7. user1 calls `claim(user1, [t0])` and reverts with division by zero (0x12) — shares unclaimable.
**How found:** Code-reading comparison of the timestamp boundary logic in _handleReport (upperLookupRecent + decrement) versus claim (lowerLookup against latestEligibleTimestamp from prices), spotting the off-by-one inconsistency, then confirming with a multi-user forge test.
**Exploitation:** Any redemption request timestamped just before a report timestamp is excluded from the created batch yet remains claim-eligible; that user claims from a batch not containing their shares, depleting it so earlier legitimate requesters cannot claim, and their shares later processed into a subsequent batch become permanently unclaimable.
**Escalation:** With larger share ratios or more queued users, the mismatch cascades: multiple users lose entitlements and shares are permanently locked across batches.
**Insight:** When a queue batches requests by timestamp, verify that the exact boundary predicate used to build a batch matches the predicate used to authorize claims — an off-by-one decrement on one side creates claimable-but-unbatched entries that drain other users' allocations.

