Project

One World
NFTDeFi
15,000 USDC
View results
Submission Details
Severity: low
Invalid

Inconsistent Message Formatting in `EIP712Base::toTypedMessageHash` Violates EIP-191 and EIP-712 Standards

Summary

The toTypedMessageHash function in the EIP712Base contract incorrectly implements the message formatting for EIP-712 signatures. Specifically, this function hashes the message using keccak256 over an incomplete EIP-191 prefix (\x19\x01) without including the message length, which violates the EIP-191 specification. This issue can affect the validity of signatures and reduce interoperability with off-chain systems expecting compliance with EIP-191 and EIP-712 standards.

Vulnerability Details

The issue lies in the toTypedMessageHash function, which is responsible for creating a hash of the message in an EIP-712 compatible format. According to EIP-191, the message should include the length of the message being signed as part of the prefixed data. The current implementation omits this step, which leads to non-compliance with the standard.

function toTypedMessageHash(bytes32 messageHash) internal view returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", getDomainSeperator(), messageHash));
}

In this code, \x19\x01 is used as a prefix to mark the message as an EIP-191 signed message. However, the message length is missing from the encoding. The correct approach, according to EIP-191 and EIP-712, is to include the message length in the signed data. This issue could lead to signatures being invalid or non-compliant with third-party tools or libraries designed for EIP-191.

Impact

Non-compliance with EIP-191 and EIP-712 can cause issues with third-party systems such as wallets, dApps, or other smart contracts that expect the correct message format, potentially causing failures in signature verification.

Tools Used

Manual Review

Recommendations

  1. Include Message Length in toTypedMessageHash Function: Modify the toTypedMessageHash function to include the length of the message being signed, as required by EIP-191. The revised function should look like this:

function toTypedMessageHash(bytes32 messageHash) internal view returns (bytes32) {
uint256 messageLength = 32; // Length of the messageHash (32 bytes)
return keccak256(abi.encodePacked("\x19\x01", getDomainSeperator(), messageLength, messageHash));
}
Updates

Lead Judging Commences

0xbrivan2 Lead Judge 12 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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