Mystery Box

First Flight #25
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: medium
Valid

M-1 Insecure Randomness Generation Vulnerability using block.timestamp and msg.sender affects the fairness and reliability of Mystery Box

Summary

The code generates a pseudo-random number using block.timestamp and msg.sender, but this approach is not secure for scenarios requiring unpredictable randomness. The inputs used can be influenced by miners or participants, making the randomness predictable.

Vulnerability Details

The current implementation for generating randomness uses the keccak256 function with block.timestamp and msg.sender as inputs. While this might suffice for non-critical randomness needs, both block.timestamp and msg.sender are not truly random and can be influenced.
For example:

  • Miners can manipulate the block timestamp within a limited range.

  • Malicious users can attempt to generate transactions at specific times, altering the msg.sender input.
    This can lead to predictable outcomes in applications requiring strong randomness, such as lotteries or games, where fairness and unpredictability are critical.

Impact

  • Potential manipulation of outcomes in lotteries, raffles, or any application that depends on fair randomness.

  • Exploitation by malicious actors to tilt the results in their favor.

Tools Used

Manual Review

Recommendations

For stronger and more secure randomness, consider integrating a Verifiable Randomness mechanism like Chainlink VRF (Verifiable Random Function). Chainlink VRF provides cryptographically secure and verifiable randomness that is resistant to manipulation, ensuring the fairness and unpredictability of outcomes in critical applications.

Updates

Appeal created

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Weak Randomness

Support

FAQs

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

Give us feedback!