Open c4-bot-6 opened 8 months ago
I don't consider this a high risk issue, because:
Rewards should be set atomically in the same transaction call by an admin script. The expectation is that if the 0 index is set, then all should be set for the round, hence the check for the zero index.
User would need to directly interact with the contract knowing that they have 0 rewards to claim, as the UI would not prompt the user to execute a transaction if they do not have any winning tickets.
I would consider this a Quality Assurance to improve the require check, or Medium at most, as reported by #17
We also use this 0 index check in other methods, like the enterTickets
function because we have the expectation mentioned in bullet point 1
0xleastwood marked the issue as satisfactory
This is a duplicate of #27
jooleseth marked the issue as disagree with severity
jooleseth (sponsor) acknowledged
Same reason as #28
0xleastwood removed the grade
0xleastwood changed the severity to QA (Quality Assurance)
I guess i should be consistent here even if the admin would atomically set the prizes all at once such that this would not happen. It's not documented so this can't be assumed.
But this is something only the admin has access to do, so if their initial plan was to atomically set the prizes then i don't believe this to be valid for medium severity still. This is not likely to happen.
Keeping it as is.
Lines of code
https://github.com/code-423n4/2024-02-thruster/blob/3896779349f90a44b46f2646094cb34fffd7f66e/thruster-protocol/thruster-treasure/contracts/ThrusterTreasure.sol#L98-L104 https://github.com/code-423n4/2024-02-thruster/blob/3896779349f90a44b46f2646094cb34fffd7f66e/thruster-protocol/thruster-treasure/contracts/ThrusterTreasure.sol#L261-L277
Vulnerability details
Impact
The
ThrusterTreasure
contract facilitates a lottery game where users can enter tickets and claim prizes based on random draws. The contract uses a combination of user ticket entries, Merkle proofs for verification, and an entropy source for drawing winning tickets.The
claimPrizesForRound()
function allows users to claim their prizes for a specific round. However, there's a significant issue where a user can claim their prize as soon as the winning tickets for the first prize index are set, without waiting for all prizes within the round to be determined. This premature claiming could lead to a scenario where users' tickets are cleared from the round after callingclaimPrizesForRound()
without receiving any prize, even if they had one or more winning tickets.ThrusterTreasure.sol#L98-L104
ThrusterTreasure.sol#L261-L277
This is considered high severity because it:
Proof of Concept
setWinningTickets()
.claimPrizesForRound()
and claims their prize.claimPrizesForRound()
.Tools Used
Manual review
Recommended Mitigation Steps
To address this issue, it is recommended to implement a mechanism that ensures all prizes for a round are set before any prize claims can be made. This could be achieved by:
claimPrizesForRound()
function to check this state variable before allowing any prize claims.A possible implementation could look like this:
This solution ensures that users can only claim prizes once all prizes for the round have been determined, preserving the fairness and integrity of the lottery.
Assessed type
Other