Mystery Box

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

Reentrancy Vulnerability in `claimAllRewards` and `claimSingleReward`

Summary

Both claimAllRewards and claimSingleReward functions involve sending Ether to users before modifying the state (clearing the rewards). This creates a reentrancy vulnerability, where an attacker can repeatedly call the function to drain funds from the contract before the state is updated.

Vulnerability Details

MysteryBox.sol/Line 79 and Line 92

Impact

Attackers could exploit this to withdraw Ether multiple times, draining the contract's funds.

Tools Used

Foundry

Recommendations

  • Always update the contract's state before making external calls.

  • Consider using ReentrancyGuard from OpenZeppelin to protect against reentrancy attacks.

  • Use transfer or send instead of call, which has limited gas to reduce reentrancy risks, although using checks-effects-interactions pattern is still better.

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:

`claimAllRewards` reentrancy

`claimSingleReward` reentrancy

Support

FAQs

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

Give us feedback!