Open code423n4 opened 1 year ago
thereksfour marked the issue as duplicate of #124
thereksfour marked the issue as not a duplicate
thereksfour marked the issue as duplicate of #322
thereksfour changed the severity to 2 (Med Risk)
thereksfour marked the issue as selected for report
thereksfour marked the issue as satisfactory
Lines of code
https://github.com/code-423n4/2023-03-wenwin/blob/91b89482aaedf8b8feb73c771d11c257eed997e8/src/Lottery.sol#L151 https://github.com/code-423n4/2023-03-wenwin/blob/91b89482aaedf8b8feb73c771d11c257eed997e8/src/staking/Staking.sol#L48
Vulnerability details
Impact
Blocking rewards assigned to stakes from the sale of lottery tickets when stakes are absent in the
Staking
contractSo, the situation is unlikely, but it can happen
Proof of Concept
In order to confirm the problem, we need to prove 2 things:
Total supply == 0:
Flow 1:
LotteryRewardType.STAKING
rewardPerToken
will start from0
andlastUpdateTicketId
will update to actually50: if (_totalSupply == 0) { // totalSupply == 0 51: return rewardPerTokenStored;
120: rewardPerTokenStored = currentRewardPerToken; // will set 0 121: lastUpdateTicketId = lottery.nextTicketId(); // set actually
Result:
Tools Used
Recommended Mitigation Steps
One of: