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

Deterministic Winner Selection Vulnerability

Summary

The winner is deterministic. The use of msg.sender, block.timestamp, block.difficulty and player. length is very predictable, especially to the miner.

Vulnerability Details

The vulnerability in the contract arises from the deterministic nature of selecting a winner based on predictable factors. Specifically, the winner selection mechanism relies on:

  1. msg.sender: The address of the sender.

  2. block.timestamp: The current timestamp.

  3. block.difficulty: The mining difficulty of the current block.

  4. players.length: The number of players participating in the raffle.

These factors, particularly block.timestamp and block.difficulty, can be easily manipulated or predicted by miners, allowing them to influence the winner selection process.

Impact

The deterministic nature of the winner selection poses a significant vulnerability. Miners or malicious actors with knowledge of the underlying blockchain can manipulate these factors to predict or control the outcome of the raffle. This can lead to unfair and potentially fraudulent results, undermining the trustworthiness of the contract.

Tools Used

Manual

Recommendations

To enhance the fairness and security of the contract, the winner selection process should be made more unpredictable and resistant to manipulation. Using a more random source of entropy, such as Chainlink VRF (Verifiable Random Function), can significantly improve the randomness and fairness of the selection process. It is also essential to avoid using easily predictable or manipulable variables like block.timestamp and block.difficulty for critical operations like winner selection.

Updates

Lead Judging Commences

Hamiltonite Lead Judge over 1 year 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.