Skip to content

Code4rena

Wenwin contest

Every publicly disclosed report for Wenwin contest and what kind of bugs they were.

disclosed reports
8
most reported class
Business logic
bug classes found
4
first disclosure
2023
Find Wenwin contest on bugbounty.fyi Current scope, rewards and status, if it runs a public program.

Disclosed reports

Newest first. Only what Wenwin contest chose to make public.

Audit finding

LotteryMath.calculateNewProfit returns wrong profit when there is no jackpot winner

The function LotteryMath.calculateNewProfit computes the expected rewards incorrectly when there is no jackpot winner, because it multiplies the total payout by a multiplier that is already a percentage, instead of applying the percentage. This causes the net profit to be wrong, which then affects reward calculations in the Lottery contract.

Wenwin contest

High
Business logic

Possibility to steal jackpot bypassing restrictions in the executeDraw()

The executeDraw function allowed calling at the exact deadline second due to a strict comparison, letting an attacker trigger the draw, read the random number, and then buy a winning ticket in the same block. This could let the attacker steal the jackpot.

Wenwin contest

Medium
Business logic

Insolvency: The Lottery may incorrectly consider a year old jackpot ticket as unclaimed and increase currentNetProfit by its prize while it was actually claimed

The lottery contract could treat a one-year-old jackpot ticket as unclaimed and add its prize to the current net profit, while the ticket owner could still claim the prize in the same transaction, leaving the contract insolvent. An attacker could exploit this edge case to receive their prize while the contract incorrectly counts it as unclaimed.

Wenwin contest

Medium
Race condition

Undermining the fairness of the protocol in swapSource() and possibilities for stealing a jackpot

The retry() function only updates maxFailedAttemptsReachedAt when failedAttempts equals maxFailedAttempts, so after that point a retry() can be front-run before swapSource() to trigger two random number requests. An attacker could then inspect the two random numbers and front-run the one that favours them, undermining fairness and potentially stealing a jackpot.

Wenwin contest

Medium
DoS

An attacker can leave the protocol in a “drawing” state for extended period of time

The protocol's random number request function uses a try/catch block that, if the external call fails, leaves the system in a state where draws cannot proceed until a delay passes. An attacker can deliberately cause the external call to fail by supplying insufficient gas, repeatedly triggering the delay and keeping the protocol in a 'drawing' state for extended periods.

Wenwin contest

Medium
Business logic

Locking rewards tokens in Staking contract when there are no stakes

The Staking contract does not update its reward accounting when total staked supply is zero, so rewards sent during such periods become permanently locked. An attacker could cause this by ensuring no tokens are staked when rewards are claimed, though the report notes the situation is unlikely.

Wenwin contest

Medium