PuppyRaffle::selectWinner computes puppy rarity as uint256(keccak256(abi.encodePacked(msg.sender, block.difficulty))) % 100 (src/PuppyRaffle.sol:139). Both inputs are known to the caller, so an attacker can compute the resulting rarity in advance and choose calling conditions (sender, target block) that guarantee a LEGENDARY mint.
Likelihood:
Medium. The attacker must be (or control) the winner-selecting caller, but given that, predicting and grinding the rarity is trivial — they iterate msg.sender candidates or wait for a block whose block.difficulty yields rarity > 95.
Impact:
Medium. The intended 70/25/5 rarity distribution is defeated. An attacker reliably mints LEGENDARY puppies, devaluing legitimately-earned rare and legendary NFTs and undermining the collection's scarcity and economic value.
The attacker checks the rarity formula off-chain and only proceeds when it resolves to LEGENDARY.
Derive rarity from a verifiable randomness source (Chainlink VRF) or a commit-reveal value rather than predictable on-chain data.
The contest is live. Earn rewards by submitting a finding.
Submissions are being reviewed by our AI judge. Results will be available in a few minutes.
View all submissionsThe contest is complete and the rewards are being distributed.