President Elector

First Flight #24
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: medium
Valid

Voters Can Manipulate Election by Overwriting Votes Before Results are Declared

Understanding the Differences Between the Issues

  • Overwriting Votes:

    • Root Cause: Lack of restrictions on updating votes within the same term.

    • Scope: Affects only the current election term.

    • Impact: Voters can manipulate outcomes by changing their votes based on real-time data.

  • Signature Replay Attacks:

    • Root Cause: Absence of unique identifiers (like s_voteNumber or nonces) in the signed data.

    • Scope: Allows reuse of signatures across different election terms.

    • Impact: Attackers can cast unauthorized votes in future elections using old signatures.

  • MEV Manipulation:

    • Root Cause: Miners' ability to control transaction ordering and inclusion.

    • Scope: External to the contract logic; depends on network-level factors.

    • Impact: Miners can include or exclude transactions to favor certain candidates.

  • Public Visibility of Votes:

    • Root Cause: Votes and voter choices are stored in plain text on-chain.

    • Scope: Anyone can access and analyze voting patterns in real-time.

    • Impact: Enables strategic voting and potential voter coercion based on visible data and person who pays for gas may chose his favourable candidates.

Summary

Voters are allowed to overwrite their votes by calling _rankCandidates multiple times before the president is selected. This allows voters to change their votes based on real-time data, potentially manipulating the election outcome.
why MEV

Vulnerability Details

  • Affected Function: _rankCandidates

  • Issue Explanation:

    • No Vote Finality: The contract does not prevent a voter from submitting multiple votes in the same voting round.

    • Strategic Voting: Voters can monitor the current standings and adjust their votes accordingly to influence the result.

    • Unfair Advantage: Voters who act last have an advantage over those who voted earlier.

Impact

  • Election Manipulation: The ability to change votes undermines the stability of the election process.

  • Unfairness: Early voters are disadvantaged compared to those who can react to ongoing results.

Tools Used

  • Manual Code Review: Observed lack of checks preventing multiple votes per voter per round.

Recommendations

  • Enforce Single Vote per Voter per Round:

    • Add a check in _rankCandidates to ensure the voter hasn't already voted in the current round.

      require(s_rankings[voter][s_voteNumber].length == 0, "Vote already cast for this round");
  • Implement Vote Finality:

    • Once a vote is cast, it should be immutable for that voting period.

  • Close Voting Before Selection:

    • Establish a voting deadline after which votes cannot be cast or changed before selectPresident is called.

  • Event Logging:

    • Emit events when votes are cast to provide transparency.

Updates

Lead Judging Commences

inallhonesty Lead Judge 9 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Voters can change their vote

Support

FAQs

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