Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: high
Valid

Stuck ethereum on contract due to reward calculation error

Summary

In any scenario where a quorum is reached and there are more votes in favour than against, less ETH will be sent from the contract than there is in the contract balance.

Vulnerability Details

Conditions:
Quorum is reached;
totalVotesFor greater than totalVotesAgainst.
totalVotesAgainst greater than 0

Impact

The contract will always have an ETH balance that cannot be withdrawn.
The amount of stuck ETH depends on the number of votes against and can be defined:

stuck ETH = rewardPerVoter * totalVotesAgainst

Recommendations

Change the calculation of rewardPerVoter (link)

uint256 rewardPerVoter = totalRewards / totalVotesFor;

or add a "skim" function that sends the "dust" of ETH to the s_creator.

Updates

Lead Judging Commences

0xnevi Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

VotingBooth._distributeRewards(): Incorrect computation of rewardPerVoter

Support

FAQs

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