Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: medium
Invalid

Potential Integer Overflow in Division Operation (Inaccurate Calculations and Creator Manipulation)

Summary

Dividing the total rewards by the total number of voters in _distributeRewards might overflow for high reward amounts and many voters, leading to inaccurate calculations and potential manipulation by the creator.

Vulnerability Details

When distributing rewards within _distributeRewards, the function calculates the individual reward for each voter by dividing the total reward amount by the total number of voters. However, this division uses simple integer arithmetic, which can overflow for large values. If the total reward or number of voters is high, the calculations might overflow, resulting in inaccurate, potentially zero, individual rewards and allowing the creator to retain a significant portion of the funds.

Impact

Inaccurate or missing reward distribution for voters, potentially benefiting the creator and undermining trust in the system.

Tools Used

  • Manual Code Review

Test Case and logs

  • Deploy the VotingBooth contract.

  • Set a high reward amount and simulate a voting process with a large number of voters.

  • Monitor the individual reward calculations within _distributeRewards.

  • Check if the total distributed rewards match the expected amount and if any overflow errors occur.

Expected Logs:

Inaccurate individual reward calculations due to overflow might lead to some voters receiving significantly less or no reward.
Total distributed rewards might not match the expected amount due to potential overflow and loss of precision.

Recommendations

  • Use safe math libraries like OpenZeppelin's SafeMath to perform calculations involving large values in _distributeRewards. These libraries implement overflow protection mechanisms to ensure accurate calculations and prevent manipulation.

  • Consider alternative approaches for reward distribution that are less susceptible to overflow, such as dividing the rewards proportionally based

Updates

Lead Judging Commences

0xnevi Lead Judge
over 1 year ago
0xnevi Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Other

Support

FAQs

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