Mystery Box

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

The function `claimAllRewards` can be hit by DDOS attack.

Summary

A Distributed Denial of Service (DDoS) attack on a smart contract aims to overwhelm the contract or the blockchain network with excessive transactions, causing delays or making the contract unusable.

Vulnerability Details

Loop in the claimAllRewards function:

for (uint256 i = 0; i < rewardsOwned[msg.sender].length; i++) {
totalValue += rewardsOwned[msg.sender][i].value;
}

Impact

Potential scenario:

An attacker can change the protocol’s ownership (due to the changeOwner function lacking an onlyOwner check), set the mysteryBox value to 0 ETH, and then use the openBox function multiple times (e.g., 100 times), effectively blocking the protocol.

Tools Used

Foundry

Recommendations

Insetd of count `totalValue` in loop better is create map

mapping(address => uint256) public totalValues;

and modifing this map during opening, transferring, or withdrawing funds.

eg.

function openBox() {
...
totalValues[msg.sender]+=reward.value;
... }
Updates

Appeal created

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

Anyone can change owner

Support

FAQs

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

Give us feedback!