Wenwin contest - minhtrng'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: 13/93

Findings: 1

Award: $619.34

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: Cyfrin

Also found by: Yukti_Chinta, adriro, anodaram, auditor0517, bin2chen, gogo, minhtrng

Labels

bug
3 (High Risk)
satisfactory
duplicate-324

Awards

619.3361 USDC - $619.34

External Links

Lines of code

https://github.com/code-423n4/2023-03-wenwin/blob/91b89482aaedf8b8feb73c771d11c257eed997e8/src/LotteryMath.sol#L52-L53

Vulnerability details

Impact

When calculating new profit, the calculation for non-jackpot rewards are not normalized and will be largely overestimated, due to the additional percentage scaling. This will lead to the excess pot for participants being much lower and hence failing to incentivize participation in the long run.

Proof of Concept

The Lottery calculates the new expected profit via LotteryMath.calculateNewProfit:

uint256 expectedRewardsOut = jackpotWon
    ? calculateReward(oldProfit, fixedJackpotSize, fixedJackpotSize, ticketsSold, true, expectedPayout)
    : calculateMultiplier(calculateExcessPot(oldProfit, fixedJackpotSize), ticketsSold, expectedPayout)
        * ticketsSold * expectedPayout;

The issue is that in the no-jackpot-case the value for expectedRewardsOut will be scaled by an additional PERCENTAGE_BASE precision (thats what calculateMultiplier returns). The value is meant to express an amount of rewardTokens though. Hence the value is too large by a factor of 1e5 and will cause the problem mentioned under #Impact.

Tools Used

Manual Review

Perform normalization via getPercentage.

#0 - c4-judge

2023-03-10T08:44:31Z

thereksfour marked the issue as duplicate of #219

#1 - c4-judge

2023-03-19T10:23:38Z

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