In the MysteryBox contract, there is an inconsistency between the reward values initialized in the constructor and the reward values allocated in the openBox function. Specifically, the rewards for Silver Coin and Gold Coin in the openBox function are incorrectly doubled compared to the values assigned in the contract's constructor.
In the constructor, the reward values are initialized as follows:
Gold Coin is valued at 0.5 ether. Silver Coin is valued at 0.25 ether.
However, in the openBox function, the rewards are distributed with doubled values:
The Silver Coin is incorrectly assigned a value of 0.5 ether (instead of the intended 0.25 ether).
The Gold Coin is incorrectly assigned a value of 1 ether (instead of the intended 0.5 ether).
This inconsistency significantly increases the reward value for both the Silver and Gold Coin compared to the expected values set in the constructor. As the result the contract will pay out twice the intended value for both Silver and Gold rewards. This could drain the contract's balance, especially if randomness is manipulated (as highlighted in a separate medium-severity issue regarding possible randomness manipulation).
Manual review, Visual Studio Code (VSCode)
To address this vulnerability, the reward values in the openBox function should be corrected to match the intended values initialized in the constructor. The following code change should be implemented:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.