Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: high
Valid

'selectWinner' function can be hijacked

Summary

Somebody can take advantage of the 'selectWinner' function through the way we compute randomness on the chain.

Vulnerability Details

A potential exploit exists where a malicious actor could manipulate outcomes by simulating transactions on a testnet (or through tools like Foundry or Tenderly). By repeatedly calling the function with varying block timestamps and block difficulties, they can identify a successful pattern. Once identified, this pattern could be replicated in a transaction on the mainnet, leading to a compromise.

An attacker can monitor the mempool (the set of unconfirmed transactions) for a transaction that successfully calls the selectWinner function. Upon spotting such a transaction, the attacker can initiate their own transaction with a higher gas fee. This maneuver ensures the attacker's transaction is processed first by the miners, effectively allowing the attacker to manipulate the outcome. This scenario becomes particularly problematic because the inclusion of their transaction changes the state of the contract (such as increasing the size of the players array), potentially causing the original transaction to fail or produce a different outcome. This vulnerability can be exploited to gain an unfair advantage or to disrupt the normal operation of the raffle.

Impact

This vulnerability can potentially undermine the integrity of the system, leading to unfair advantages and loss of trust among users.

Tools Used

Manual review

Recommendations

To mitigate this risk, it is advisable to integrate Chainlink's Verifiable Random Function (VRF) for more secure and verifiable on-chain randomness. This approach will greatly enhance the fairness and security of the 'selectWinner' function.

Updates

Lead Judging Commences

Hamiltonite Lead Judge about 2 years ago
Submission Judgement Published
Validated
Assigned finding tags:

weak-randomness

Root cause: bad RNG Impact: manipulate winner

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!