Platform: Code4rena
Start Date: 17/03/2023
Pot Size: $36,500 USDC
Total HM: 10
Participants: 98
Period: 3 days
Judge: leastwood
Total Solo HM: 5
Id: 223
League: ETH
Rank: 43/98
Findings: 1
Award: $39.87
🌟 Selected for report: 0
🚀 Solo Findings: 0
39.8657 USDC - $39.87
Detailed description of the impact of this finding.
The iteratePRNG()
function in the Utils.sol
library is used in Tray.sol:_drawing()
, which is used to determine the tile data that a user gets when they purchase an NFT in Tray.sol:buy()
. An attacker can exploit this to guarantee that they receive a rare/desirable mint.
Provide direct links to all referenced code in GitHub. Add screenshots, logs, or any other relevant proof that illustrates the concept.
iteratePrng
does not actually generate randomness, instead using the previous number to compute each new pseudo-random number. This allows an attacker to precompute any data that relies on this function.
Because the 'randomness' for the tile data in Tray.sol:buy()
relies on iteratePRNG()
(indirectly via _drawing()
), An attacker can either 1) precompute the tile data and wait for a desirable lastHash
before they buy, or 2) call buy() -> check the tile data -> revert if it's not desirable/rare. Both options guarantee that they receive an NFT with data/traits that they want.
This scenario is similar to the Wolf Game Exploit.
Manual review
#0 - c4-judge
2023-03-28T18:48:31Z
0xleastwood marked the issue as duplicate of #121
#1 - c4-judge
2023-04-11T19:55:01Z
0xleastwood marked the issue as satisfactory
#2 - c4-judge
2023-04-11T20:03:26Z
0xleastwood marked the issue as duplicate of #121
#3 - c4-judge
2023-04-12T00:55:04Z
0xleastwood marked the issue as duplicate of #130
#4 - c4-judge
2023-04-12T00:59:55Z
0xleastwood marked the issue as partial-50