The quorum check in vote
function uses integer division, which could truncate the fractional part of the result and underestimate the true vote proportion. This could result in unfair proposal outcomes, as the proposal could pass or fail without reaching the minimum quorum of 51%.
The quorum check in vote
function is supposed to check if at least 51% of the total allowed voters have cast their vote. However, it uses integer division, which could truncate the fractional part of the result and round it down. For example, if there are 5 allowed voters and 3 of them have voted, the result of the division would be 60, which is greater than the minimum quorum of 51. However, if one of the voters votes against, the proposal should not pass, as the true vote proportion is 50%. Similarly, if there are 4 allowed voters and 2 of them have voted, the result of the division would be 50, which is less than the minimum quorum of 51. However, if both of the voters vote for, the proposal should pass, as the true vote proportion is 50%.
This could result in unfair proposal outcomes, as the proposal could pass or fail without reaching the minimum quorum of 51%. This could also affect the reward distribution or refund, as the contract could transfer funds based on an incorrect proposal outcome.
The impact of this vulnerability is that the contract could approve or reject proposals without reaching the minimum quorum of 51%. This could undermine the integrity and fairness of the voting process, as the proposal outcome could be influenced by a minority of voters. This could also affect the reward distribution or refund, as the contract could transfer funds based on an incorrect proposal outcome.
Manual Review
The following test case demonstrates how this vulnerability could result in unfair proposal outcomes:
Deploy the contract with an array of 5 allowed voters and 1 ether as the reward.
Call the vote function from 3 of the allowed voters, with 2 voting for and 1 voting against.
Observe that the proposal passes and the rewards are distributed to the 2 voters who voted for, even though the true vote proportion is 50%.
Use a more precise way of calculating the vote proportion, such as using a library like SafeMath
or using fixed-point arithmetic. This way, you can avoid truncation and rounding errors and ensure that the quorum check is accurate and fair.
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.