<!-- canonical: https://0xsimao.com/findings/orange-domain-separator-fork-safe -->

# Domain separator calculation is not fork safe

Medium · Three Sigma · Cross-chain bridge · 15th July, 2024

Finding 3S-OB-L07 of the Orange Bridge security review.

- Protocol: https://www.orangeweb3.com/
- Report: /reports/orange
- Source: https://cdn.sanity.io/files/qoqld077/production/686ad4e1d5035d69002f5f97e281e3c5a8b7ce00.pdf

---

### Description

The domain separator is cached in the constructor of the [contracts](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/EIP712.sol#L80-L86), which could lead to
signature signing softwares in case of a hard fork. When a hard fork happens,
block.chainid changes, which affects the domain separator, but as it is only computed in
the constructor, it will be forever incorrect. Messages can still be signed but EIP712 will be
broken.

### Recommendation

The EIP712 contract from OpenZeppelin handles this by caching the original domain
separator and recomputing it if block.chainid has changed.

### Status

Addressed in [#143cee8](https://github.com/orangecryptohq/orange-bridge-contract/commit/143cee88bcb606bb7c898943e7d3c6f15091eb93).
