The contract suffers from a critical vulnerability in the reward distribution mechanism during the _distributeRewards
process. The flaw arises from an inaccurate calculation of the rewardPerVoter
, where the total rewards are divided by the combined number of votes ('For' and 'Against'). This oversight leads to an unequal distribution of ETH rewards among voters, with excess ETH being locked in the contract. The vulnerability undermines the core functionality of the contract, impacting the fairness and reliability of the voting reward system.
In the _distributeRewards
function, the calculation of rewardPerVoter
is flawed. The division of totalRewards
by totalVotes
is used to determine the reward for each voter. However, this approach results in an inaccurate distribution, as it fails to consider the distinction between For
and Against
votes. The flawed logic leads to an uneven distribution of rewards, leaving excess ETH locked in the contract.
The impact of this vulnerability is significant, affecting the fairness and reliability of the voting reward system. As a consequence, voters receive an incorrect share of the rewards, leading to potential disputes and a loss of trust in the contract's intended functionality. Additionally, the excess ETH locked in the contract may be perceived as an economic inefficiency.
The analysis was conducted through manual code review and testing scenarios, including a test case designed to demonstrate the flawed reward distribution.
To address this vulnerability, the contract's reward distribution mechanism should be redesigned. The calculation of rewardPerVoter
needs to account for the total number of voters who voted For
the proposal rather than considering all votes collectively. A more accurate calculation would involve dividing totalRewards
by totalVotesFor
. Additionally, it is recommended to handle any remainder in a controlled manner to avoid leaving excess ETH locked in the contract.
Example Fix:
By making these adjustments, the contract can ensure a fair and accurate distribution of rewards based on the number of votes 'For' the proposal.
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.