President Elector

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

Wrong parameter in constant `TYPEHASH`

Summary

Description: There is a wrong parameter in constant TYPEHASH, it must be an array of address type but not uint256 type.

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

Vulnerability Details

We use TYPEHASH in rankCandidatesBySig function to get structHash, but as it is wrong , users will not be able to cast votes of other users using rankCandidatesBySig function.

function rankCandidatesBySig(
address[] memory orderedCandidates,
bytes memory signature
) external {
- bytes32 structHash = keccak256(abi.encode(TYPEHASH, orderedCandidates));
bytes32 hash = _hashTypedDataV4(structHash);
address signer = ECDSA.recover(hash, signature);
_rankCandidates(orderedCandidates, signer);
}

Recommendations

Change value type to address

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

Lead Judging Commences

inallhonesty Lead Judge 11 months 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.