Mystery Box

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

Insecure Randomness Source

Summary

The MysteryBox::openBox() function uses block.timestamp and msg.sender to generate randomness for the rewards. These values are predictable and can be manipulated by an attacker to gain favorable rewards.

Vulnerability Details

Affected Code

uint256 randomValue = uint256(keccak256(abi.encodePacked(block.timestamp, msg.sender))) % 100;

Impact

The attacker can manipulate the reward generation process to receive more valuable rewards by controlling the transaction’s timestamp and address.

Tools Used

  • Visual Studio Code

  • Solidity

  • Foundry

Recommended Mitigation

Use a more secure source of randomness, such as Chainlink VRF or a method that introduces more entropy.

Updates

Lead Judging Commences

inallhonesty Lead Judge
about 1 year ago

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.