# Invalid validation in _farmPlots function allowing a malicious user repeated farming without locked funds

Off-by-one in LandManager._farmPlots lets plotId 0 keep farming rewards after landlord unlocks all funds, minting unbacked rewards.

- Payout: Audit contest
- Severity: high
- Program: Munchables
- Found by: gd
- Disclosed: 2024-08-16
- Write-up quality: 7/10
- Original: https://github.com/code-423n4/2024-07-munchables-findings/issues/87
- Library page: https://bugbountylibrary.com/r/c4%3A2024-07-munchables%3AH-02
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:code4rena sev:high tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:business-logic

**Target:** LandManager.sol _farmPlots / stakeMunchable
**Root cause:** The dirty-plot check uses strict `<` instead of `<=`, so when _getNumPlots returns 0 (all funds unlocked), plotId 0 still passes validation and remains farmable.
**Steps:**
1. Landlord locks funds and creates plots; user stakes Munchable NFT on plotId 0 via `stakeMunchable(alice, 1, 0)`
2. Landlord calls `unlock(zeroAddress, 1 ether)` removing all locked funds
3. User calls `farmPlots([])` immediately — rewards still accrue to plot 0
4. Fast-forward past unlockTime + 30 days and call `farmPlots([])` again
5. Observe user's unfedSchnibbles grows despite landlord having no locked funds
**How found:** Code review of the plot validation logic: noticed _getNumPlots returns 0 after full unlock but the strict `<` comparison fails to invalidate plotId 0, the boundary case.
**Exploitation:** Attacker stakes an NFT on plotId 0 of a landlord, waits for landlord to unlock all funds, then repeatedly calls farmPlots to accrue rewards with no staked capital backing them, extracting value from the game economy.
**Insight:** When a validation compares an index/count with `<`, always test the zero-index boundary: a count of 0 should invalidate index 0, requiring `<=` not `<`.

