Mystery Box

First Flight #25
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: low
Invalid

Impractical Strict Price Check in MysteryBox::buyBox()

Summary

The MysteryBox::buyBox() function requires an exact amount of ETH to be sent when purchasing a box, making the transaction strict and possibly inconvenient for users.

Vulnerability Details

Affected Code

require(msg.value == boxPrice, "Incorrect ETH sent");

Impact

Users who overpay will face transaction failures, causing a poor user experience.

Tools Used

  • Visual Studio Code

  • Solidity

  • Foundry

Recommended Mitigation

Allow users to send more ETH and refund any excess.

require(msg.value >= boxPrice, "Insufficient ETH sent");
uint256 refund = msg.value - boxPrice;
if (refund > 0) {
payable(msg.sender).transfer(refund);
}
Updates

Appeal created

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

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