Project

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

`EIP712Base` logic is susceptible to signature replay attacks in the case of a hard fork

Summary

The EIP712Base logic is susceptible to signature replay attacks following a hard fork of the blockchain. This vulnerability arises from the way the domainSeperator is computed and stored.

Vulnerability Details

The domainSeperator is computed using a chain ID, which is derived at the time of contract deployment using getChainId():

bytes32 internal domainSeperator;
constructor(
string memory name,
string memory version
){
_setDomainSeperator(name, version);
}
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 getDomainSeperator() public view returns (bytes32) {
return domainSeperator;
}
function getChainId() public view returns (uint256) {
uint256 id;
assembly {
id := chainid()
}
return id;
}

This value is incorporated into the domainSeperator and remains immutable for the lifetime of the contract.

If a hard fork occurs, the chain ID may change, resulting in a situation where the domainSeperator created on the original chain is effectively valid on both chains. That means signatures generated from messages signed on one chain could be replayed on the other chain (the forked network) because the domainSeperator remains valid across both chains.

An attacker can capture signatures from the original chain and attempt to replay those signatures on the forked chain. Since the contract does not differentiate between the two chains in its signature validation logic, and assumes that the domainSeperator uniquely identifies the contract state, it can unintentionally accept these signatures, leading to potential unauthorized actions, fund transfers, or misrepresentations of user intents.

Impact

The EIP712Base logic is susceptible to signature replay attacks following a hard fork of the blockchain.

Tools Used

Manual Review

Recommendations

Consider using openzeppelin's [EIP712](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.0.2/contracts/utils/cryptography/EIP712.sol).

Updates

Lead Judging Commences

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

Appeal created

0xbrivan2 Lead Judge 10 months ago
Submission Judgement Published
Validated
Assigned finding tags:

can't update domainSeparator in case of hard fork

Support

FAQs

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