EIP-712 domain type hash mismatch breaks signature-based delegation
The contract's EIP-712 domain type hash omits the version field, but the domain separator is built with a version value included, so the two do not match. As a result, signatures produced for the delegation feature would not verify and delegateBySig would always fail.
Originally disclosed on Code4rena
Submitted by newspacexyz
Finding description
There is a mistake in how the DOMAIN_TYPEHASH constant is defined and used in the VotingEscrow contract.
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
However, when building the domain separator, the contract includes an additional parameter:
bytes32 domainSeparator = keccak256(
abi.encode(
DOMAIN_TYPEHASH,
keccak256(bytes(name)),
keccak256(bytes(version)),
block.chainid,
address(this)
)
);
The problem is that the DOMAIN_TYPEHASH does not include the version parameter, but the contract still tries to encode it. This creates a mismatch between the type hash and the actual encoding, which will lead to incorrect digest hashes when signing or verifying messages.
Impact
- Users will be unable to sign or verify messages using the EIP-712 delegation feature.
- Delegation by signature (
delegateBySig) will always fail due to signature mismatch. - Governance features relying on off-chain signatures will break.
Recommended mitigation steps
Update the DOMAIN_TYPEHASH to include the version field so that it matches the data structure used in the actual domainSeparator:
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
This change ensures the type hash includes all the fields being encoded and fixes the signature validation logic.
Blackhole marked as informative
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The DOMAIN_TYPEHASH string does not list the version field, while the domain separator encoding includes a version hash, so the declared type and the encoded data differ.
Impact
Signature-based delegation would always fail, breaking delegateBySig and any governance flow that relies on off-chain signatures; the project marked the finding as informative.
What the attacker needed
None
The fix
The type hash should be updated to include the version field so it matches the encoded domain separator.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
EIP-712 is a standard for signing structured data so a contract can check who approved something. The contract declares which fields a signature covers in one place, but builds the actual signed data with an extra field, so the two descriptions disagree. Because they disagree, every signature check fails and the feature cannot be used.
What is Crypto?
Encryption, signatures, randomness or certificate checks that do not protect what they claim to.