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: 60/93
Findings: 1
Award: $21.70
๐ Selected for report: 0
๐ Solo Findings: 0
๐ Selected for report: adriro
Also found by: 0x1f8b, 0xAgro, 0xSmartContract, 0xfuje, 0xkazim, 0xnev, Aymen0909, Bason, Cyfrin, DadeKuma, LethL, Madalad, MohammedRizwan, Rolezn, SAAJ, SunSec, Udsen, Yukti_Chinta, ast3ros, bin2chen, brgltd, bshramin, btk, bugradar, catellatech, cryptostellar5, descharre, dontonka, erictee, fatherOfBlocks, georgits, glcanvas, hl_, horsefacts, igingu, juancito, lukris02, martin, nadin, nomoi, peanuts, pipoca, sakshamguruji, seeu, slvDev, tnevler, zaskoh
21.7018 USDC - $21.70
The retry() function here https://github.com/code-423n4/2023-03-wenwin/blob/main/src/RNSourceController.sol#L60-L74 calculates failed attempts and stores them in a variable. If the value of the failed attempts goes beyond
the maxFailedAttempts
the owner can call the function swapSource here https://github.com/code-423n4/2023-03-wenwin/blob/main/src/RNSourceController.sol#L89
The flaw is that user can keep calling the retry function to generate the random number from the old source
until the owner calls the swapSource.
Consider for some reason the owner is unable to call the swapSource , then the user would not be able to generate a new fresh random number , and waits for the owner to call the swapSource to get the functionality working again.
Recommendation:
Add a check like this require (failedAttempts <= maxFailedAttempts)
According to the chainlink documentation here https://docs.chain.link/vrf/v2/security/#choose-a-safe-block-confirmation-time-which-will-vary-between-blockchains the requestConfirmation value should be greater than a minimum threshold value , in principle the longer we wait the safer the secure the random value is.
In principle, miners/validators of your underlying blockchain could rewrite the chainโs history to put a randomness request from your contract into a different block, which would result in a different VRF output.
Affected LOC: https://github.com/code-423n4/2023-03-wenwin/blob/main/src/VRFv2RNSource.sol#L23
According to the chainlink documentation https://docs.chain.link/vrf/v2/security/#fulfillrandomwords-must-not-revert the function fulfillRandomWords (https://github.com/code-423n4/2023-03-wenwin/blob/main/src/VRFv2RNSource.sol#L32) should not revert and it does in the function. The current implementation of WenWin only intends to call it once and it does seem that this is harmless, but if they decide to get an upgrade which includes multiple random values this can be problematic , VRF service will not attempt to call it a second time.
This issue is regarding the LotteryToken.sol This is a very common issue, and it has already caused millions of dollars in losses for lots of token users! More details here https://docs.google.com/document/d/1Feh5sP6oQL1-1NHi-X1dbgT3ch2WdhbXRevDN681Jv4/edit
Recommendation:
Add the following code to the transfer(_to address, ...) function:
require( _to != address(this) );
Currently, the total supply of the tokens is minted to the owner of the contract, and the distribution of tokens is controlled by the owner.
https://github.com/code-423n4/2023-03-wenwin/blob/main/src/LotteryToken.sol#L19 Consider transferring the tokens initially to a multi-sig account so that the tokens are protected by multiple members during the distribution and vesting period.
#0 - c4-judge
2023-03-12T09:50:07Z
thereksfour marked the issue as grade-b
#1 - c4-sponsor
2023-03-14T11:10:28Z
0xluckydev marked the issue as sponsor disputed
#2 - thereksfour
2023-03-17T13:36:47Z
2L 2 INFO B