Open sherlock-admin2 opened 9 months ago
1 comment(s) were left on this issue during the judging contest.
takarez commented:
invalid: when the contract is paused; major functions are meant to stop working; and the chance of pausing is very low as it happen during an emergency
The above comment is incorrect, since this can potentially impact outcome of game by bypassing an explicit rule/invariant of fixed 100 deposits per round, this should constitute medium severity
LooksRare/contracts-yolo#180
Fix LGTM!
HSP
medium
The number of deposits in a round can be larger than MAXIMUM_NUMBER_OF_DEPOSITS_PER_ROUND
Summary
The number of deposits in a round can be larger than MAXIMUM_NUMBER_OF_DEPOSITS_PER_ROUND, because there is no such check in depositETHIntoMultipleRounds() function or rolloverETH() function.
Vulnerability Detail
depositETHIntoMultipleRounds() function is called to deposit ETH into multiple rounds, so it's possible that the number of deposits in both current round and next round is MAXIMUM_NUMBER_OF_DEPOSITS_PER_ROUND.
When current round's number of deposits reaches MAXIMUM_NUMBER_OF_DEPOSITS_PER_ROUND, the round is drawn:
_drawWinner() function calls VRF provider to get a random number, when the random number is returned by VRF provider, fulfillRandomWords() function is called to chose the winner and the next round will be started:
If the next round's deposit number is also MAXIMUM_NUMBER_OF_DEPOSITS_PER_ROUND, _startRound() function may also draw the next round as well, so it seems that there is no chance the the number of deposits in a round can become larger than MAXIMUM_NUMBER_OF_DEPOSITS_PER_ROUND:
However, _startRound() function will draw the round only if the protocol is not paused. Imagine the following scenario:
round 1
andround 2
is MAXIMUM_NUMBER_OF_DEPOSITS_PER_ROUND;round 1
is drawn, before random number is sent back by VRF provider, the protocol is paused by the admin for some reason;round 2
;round 2
is set to OPEN but not drawn;round 2
by calling depositETHIntoMultipleRounds() function or rolloverETH() function, this will make the deposit number ofround 2
larger than MAXIMUM_NUMBER_OF_DEPOSITS_PER_ROUND.Please run the test code to verify:
Impact
This issue break the invariant that the number of deposits in a round can be larger than MAXIMUM_NUMBER_OF_DEPOSITS_PER_ROUND.
Code Snippet
https://github.com/sherlock-audit/2024-01-looksrare/blob/main/contracts-yolo/contracts/YoloV2.sol#L312 https://github.com/sherlock-audit/2024-01-looksrare/blob/main/contracts-yolo/contracts/YoloV2.sol#L643-L646
Tool used
Manual Review
Recommendation
Add check in _depositETH() function which is called by both depositETHIntoMultipleRounds() function and rolloverETH() function to ensure the deposit number cannot be larger than MAXIMUM_NUMBER_OF_DEPOSITS_PER_ROUND: