stakeMunchable is not considering if the plot metadata exist or not during staking, which allow a player to stake on a plot with zero tax rate for the landlord, which is unexpected and seems to warrant Medium severity.
Impact
Player can stake on a plot with a zero tax rate which bypass the range [MIN_TAX_RATE, MAX_TAX_RATE]
PoC
Alice and Bob are the players. Alice has some ETH locked (so a potential landlord) but somehow didn't generate his plot metadata yet.
1) Bob's stake NFT 1 on Alice's plotId 0.
If we examine all the checks, nothing is verifying if the plot's metadata exist. _getNumPlots(landlord) is not generating nor doing any check either. So the toilerState will be created with a zero tax rate (plotMetadata[landlord].currentTaxRate == 0 as doesn't exist yet).
Lines of code
https://github.com/code-423n4/2024-07-munchables/blob/main/src/managers/LandManager.sol#L166
Vulnerability details
Description
stakeMunchable
is not considering if the plot metadata exist or not during staking, which allow a player to stake on a plot withzero tax rate
for the landlord, which is unexpected and seems to warrantMedium
severity.Impact
Player can stake on a plot with a zero tax rate which bypass the range [MIN_TAX_RATE, MAX_TAX_RATE]
PoC
Alice and Bob are the players. Alice has some ETH locked (so a potential landlord) but somehow didn't generate his plot metadata yet. 1) Bob's stake NFT 1 on Alice's plotId 0.
If we examine all the checks, nothing is verifying if the plot's metadata exist.
_getNumPlots(landlord)
is not generating nor doing any check either. So thetoilerState
will be created with a zero tax rate (plotMetadata[landlord].currentTaxRate == 0 as doesn't exist yet).2) Bob will be able to farm as normally, but the landlord will not earn any points.
By examining the code below, we can see that
schnibblesLandlord
will always be zero (as _toiler.latestTaxRate == 0), which is unexpected.Tools Used
Manual review
Recommended Mitigation Steps
Apply the following patch to resolve this issue.
Assessed type
Error