President Elector

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

Incorrect type in TYPEHASH

Relevant GitHub Links

https://github.com/Cyfrin/2024-09-president-elector/blob/main/src/RankedChoice.sol#L23

Summary

The TYPEHASH variable is defined as the hash of the RankedChoice::rankCandidates function selector. However, in TYPEHASH, the parameter is incorrectly defined as uint256[], while in the RankedChoice::rankCandidates function, the parameter is actually address[].

Impact

When looking at the RankedChoice::rankCandidates function, a voter might sign a hashed message with a different function selector (keccak256("rankCandidates(address[])")), which could block them from voting in the election.

Recommendations

Update TYPEHASH to the correct value:

- bytes32 public constant TYPEHASH = keccak256("rankCandidates(uint256[])");
+ bytes32 public constant TYPEHASH = keccak256("rankCandidates(address[])");
Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Typehash hashes the wrong function input.

Support

FAQs

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