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

A voter voting against leaves funds trapped in the contract.

Summary

In the instance when there is a vote against by a voter but the proposal passes, reward funds are distributed incorrectly leaving funds trapped in the contract, there is no withdraw functionality so the funds are trapped indefinitely.

Vulnerability Details

Rewards per voter are currently calculated by the following

uint256 rewardPerVoter = totalRewards / totalVotes;

Lets use an example where there are 7 total voters with minimum quorum being reached after 4 votes with 3 "for" votes and 1 "against", if the total reward is 1 ETH, the rewards distribution would be calculated like so

1 ETH / 4 votes = 0.25 ETH per voter

However the rewards are only distributed to the "for" voters

_sendEth(s_votersFor[i], rewardPerVoter);

This means a distribution like this :

for voter 1: 0.25 ETH
for voter 2: 0.25 ETH
for voter 3: 0.25 ETH

This leaves 0.25 ETH still in the contract with no method to withdraw

Impact

Funds are lost indefinitely.

Tools Used

Foundry

Recommendations

rewardPerVoter should calculated by totalRewards / totalVotesFor this distributes all reward funds evenly to the "for" voters.

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.