The code contains a discrepancy in the reward distribution logic within the contract. The variable rewardPerVoter
is calculated based on the total rewards divided by the total votes, yet it's solely distributed among those who voted for a proposal, excluding those who voted against it. Consequently, this mismatch in calculation and distribution leads to an accumulation of unallocated funds within the contract.
The vulnerability lies in the disparity between the computation of rewardPerVoter
and its allocation. The code computes the reward per voter based on the total rewards divided by the total votes, including both votes for and against a proposal. However, it only distributes this reward to the voters who supported the proposal, leaving out those who voted against it. This inconsistency results in unassigned funds that remain locked within the contract after the voting cycle.
The following test will fail proving the problem:
Misaligned reward distribution permanently locks funds within the contract. These inaccessible funds, intended for all voters, remain immobilized as they're only distributed to supporting voters. This immobilization limits financial flexibility and fair distribution, necessitating resolution for better fund utilization and equitable rewards.
Testing with foundry
One of the following:
Refine Reward Distribution Logic: Refactor the reward distribution mechanism to accurately allocate funds exclusively among voters who supported the proposal. This adjustment ensures that the distribution process aligns with the computed rewardPerVoter
specifically for supporting voters, maintaining fairness and transparency within the voting system.
Refund Unallocated Funds: Implement a process to refund the unassigned funds within the contract to the proposer. This action rectifies the discrepancy and prevents the accumulation of unused funds.
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.