# Liquidated positions will still accrue rewards after being liquidated

Liquidated NFT positions keep accruing MasterChef rewards because NFTRewardsDistributor balances are never updated on liquidation, letting liquidated users steal rewards.

- Payout: Audit contest
- Severity: high
- Program: New Scope
- Found by: 0xNirix
- Disclosed: 2024-06-27
- Write-up quality: 7/10
- Original: https://github.com/sherlock-audit/2024-06-new-scope-judging/issues/312
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-06-new-scope%3AH-8
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:evm tech:solidity technique:source-review vuln:business-logic vuln:reward-distribution

**Target:** NFTRewardsDistributor / NFTPositionManager reward accounting in lending pool
**Root cause:** Liquidation path does not call back into NFTPositionManager/NFTRewardsDistributor to update the position's _balances, so earned() keeps using the pre-liquidation asset balance.
**Steps:**
1. Deploy NFTPositionManager behind proxy, initialize with poolFactory, address(0x123123), owner, tokenA and wethToken.
2. Grant REWARDS_ALLOCATOR_ROLE and call `notifyRewardAmount(10e18, address(pool), address(tokenA), false)`.
3. Alice mints NFT, supplies 550 ether tokenA, borrows 100 ether tokenB.
4. Bob supplies tokenB/tokenA and liquidates Alice via `pool.liquidateSimple(address(tokenA), address(tokenB), pos, 550 ether)` after oracle drop.
5. `vm.warp(block.timestamp+14 days)` and call `nftPositionManager.earned(1, assetHashA)` — Alice's rewards equal Bob's despite liquidation.
**How found:** Auditor traced reward accounting in NFTRewardsDistributor.earned() and noticed _balances[tokenId][assetHash] is only updated on supply/withdraw/borrow/repay, not on liquidation, then wrote a Foundry PoC comparing liquidated vs healthy position rewards.
**Exploitation:** Liquidated borrower keeps the NFT position registered; reward distributor never zeroes _balances on liquidation, so the position continues earning the full reward share for the entire cycle and can withdraw accrued rewards at will, diluting honest suppliers.
**Insight:** When a protocol uses a MasterChef-style accumulator keyed by a position token, enumerate every state transition that changes the underlying balance (liquidation, bad-debt writeoff, forced close) and verify each one calls the reward-sync hook — liquidation is the commonly missed path.

