Wenwin contest - d3e4's results

The next generation of chance-based gaming.

General Information

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

Wenwin

Findings Distribution

Researcher Performance

Rank: 9/93

Findings: 2

Award: $713.63

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: dingo2077

Also found by: 0x73696d616f, Blockian, d3e4, savi0ur

Labels

bug
2 (Med Risk)
satisfactory
duplicate-343

Awards

407.7933 USDC - $407.79

External Links

Lines of code

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

Vulnerability details

Impact

Frontiness rather than luck may determine the winner.

Proof of Concept

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.

Tools Used

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

Findings Information

🌟 Selected for report: MiloTruck

Also found by: adriro, anodaram, d3e4, kaden, nomoi

Labels

bug
2 (Med Risk)
satisfactory
duplicate-245

Awards

305.845 USDC - $305.84

External Links

Lines of code

https://github.com/code-423n4/2023-03-wenwin/blob/91b89482aaedf8b8feb73c771d11c257eed997e8/src/LotterySetup.sol#L164-L176

Vulnerability details

Impact

Fixed rewards may change when packed.

Proof of Concept

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$.

Tools Used

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

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter