Project

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

Incorrect Encoding of `chainId` as `bytes32` Instead of `uint256` in Domain Separator Calculation violates `EIP-712`

Summary

In the domainSeparator calculation within _setDomainSeperator, chainId is cast to bytes32 instead of being used as a uint256. According to the EIP-712 standard, chainId should be included in the domain separator as a uint256. This encoding error violates the standard, causing an incorrect domain separator and potential failures in signature verification.

Vulnerability Details

In _setDomainSeperator, chainId is encoded as follows:

function _setDomainSeperator(string memory name, string memory version) internal {
domainSeperator = keccak256(
abi.encode(
EIP712_DOMAIN_TYPEHASH,
keccak256(bytes(name)),
keccak256(bytes(version)),
address(this),
@> bytes32(getChainId())
)
);
}
function getChainId() public view returns (uint256) {
uint256 id;
assembly {
id := chainid()
}
return id;
}

This cast converts chainId from uint256 to bytes32, leading to an incorrect data format.

EIP-712 specifies that chainId MUST be a uint256. Using bytes32(getChainId()) results in a mismatch, as the encoded data structure does not match the expected structure, invalidating the domain separator for signature verification.

Impact

Due to this encoding mismatch, any signatures generated or verified against this domain separator may fail, as the separator does not accurately represent the signing domain’s structure as per the standard.

Tools Used

Manual Review

Recommendations

Change chainId from bytes32 to uint256

Updates

Lead Judging Commences

0xbrivan2 Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Known issue

Appeal created

0xshoonya Submitter
9 months ago
0xbrivan2 Lead Judge
9 months ago
0xbrivan2 Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Known issue

Support

FAQs

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