Platform: Code4rena
Start Date: 06/03/2023
Pot Size: $36,500 USDC
Total HM: 8
Participants: 93
Period: 3 days
Judge: cccz
Total Solo HM: 3
Id: 218
League: ETH
Rank: 9/93
Findings: 2
Award: $713.63
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: dingo2077
Also found by: 0x73696d616f, Blockian, d3e4, savi0ur
407.7933 USDC - $407.79
https://github.com/code-423n4/2023-03-wenwin/blob/91b89482aaedf8b8feb73c771d11c257eed997e8/src/LotterySetup.sol#L65-L70 https://github.com/code-423n4/2023-03-wenwin/blob/91b89482aaedf8b8feb73c771d11c257eed997e8/src/LotterySetup.sol#L156-L158
Frontiness rather than luck may determine the winner.
drawCoolDownPeriod
may be set to 0. Then a ticket may be bought in the same block as the draw. This allows for frontrunning the randomly selected winning ticket with a ticket purchase with this, now known, winning combination.
Code inspection
Require that drawCoolDownPeriod
> 0 so that the ticket must be bought in a block before the draw.
#0 - c4-judge
2023-03-11T10:52:53Z
thereksfour marked the issue as duplicate of #141
#1 - c4-judge
2023-03-19T10:07:27Z
thereksfour marked the issue as satisfactory
305.845 USDC - $305.84
Fixed rewards may change when packed.
In LotterySetup.packFixedRewards`
function packFixedRewards(uint256[] memory rewards) private view returns (uint256 packed) { if (rewards.length != (selectionSize) || rewards[0] != 0) { revert InvalidFixedRewardSetup(); } uint256 divisor = 10 ** (IERC20Metadata(address(rewardToken)).decimals() - 1); for (uint8 winTier = 1; winTier < selectionSize; ++winTier) { uint16 reward = uint16(rewards[winTier] / divisor); if ((rewards[winTier] % divisor) != 0) { revert InvalidFixedRewardSetup(); } packed |= uint256(reward) << (winTier * 16); } }
there is no check that the fixed rewards are less than $6553.6$. The values are packed using 16 bits which means that any reward
greater than 2**16 - 1
will be capped at L170. One decimal is used which means that 2**16 - 1
corresponds to $6553.5$.
Code inspection
If $6553.5$ is considered sufficient as a maximal value, check that this is not exceeded.
#0 - c4-judge
2023-03-11T10:46:43Z
thereksfour marked the issue as duplicate of #424
#1 - c4-judge
2023-03-11T10:46:53Z
thereksfour marked the issue as duplicate of #424
#2 - c4-judge
2023-03-19T10:01:52Z
thereksfour marked the issue as satisfactory