stakeMunchable() can be frontrunned by calling transferToUnoccupiedPlot to transfer to the plotId intended to be occupied by another staker to cause DOS #300
Stakers stake their munchables tokens on plots to farm schinbbles by specifiying the plotId they want to start farming.
This can however be frontrunned by a user who already owns different plotId by transfering to the plot before the stake is executed, this will cause the stake to revert because the plotId is now occupied.
Impact
This will lead to DOS for stakers seeking beneficial tax rates if the landlord have a good tax rate. And this will also deny staking if the gets frontrunned will trying to stake into a plot.
transferToUnoccupiedPlot can be called at anytime to move from one occupied plot to another unoccupied plot, in this case the transfer will be to the incoming staker plotId.
Tools Used
Manual Review
Recommended Mitigation Steps
Include a time buffer before allowing transfer of stakes from one plot to another.
Lines of code
https://github.com/code-423n4/2024-07-munchables/blob/94cf468aaabf526b7a8319f7eba34014ccebe7b9/src/managers/LandManager.sol#L131-L171 https://github.com/code-423n4/2024-07-munchables/blob/94cf468aaabf526b7a8319f7eba34014ccebe7b9/src/managers/LandManager.sol#L199-L226
Vulnerability details
Stakers stake their munchables tokens on plots to farm schinbbles by specifiying the
plotId
they want to start farming. This can however be frontrunned by a user who already owns differentplotId
by transfering to the plot before the stake is executed, this will cause the stake to revert because theplotId
is now occupied.Impact
This will lead to DOS for stakers seeking beneficial tax rates if the landlord have a good tax rate. And this will also deny staking if the gets frontrunned will trying to stake into a plot.
Proof of Concept
https://github.com/code-423n4/2024-07-munchables/blob/94cf468aaabf526b7a8319f7eba34014ccebe7b9/src/managers/LandManager.sol#L131-L171
https://github.com/code-423n4/2024-07-munchables/blob/94cf468aaabf526b7a8319f7eba34014ccebe7b9/src/managers/LandManager.sol#L199-L226
transferToUnoccupiedPlot
can be called at anytime to move from one occupied plot to another unoccupied plot, in this case the transfer will be to the incoming stakerplotId
.Tools Used
Manual Review
Recommended Mitigation Steps
Include a time buffer before allowing transfer of stakes from one plot to another.
Assessed type
Context