# Cached DOMAIN_SEPARATOR is incorrect for tranche tokens potentially breaking permit integrations

TrancheToken caches DOMAIN_SEPARATOR in constructor before name is set, so permit signatures built with the real name always revert.

- Payout: Audit contest
- Severity: medium
- Program: Centrifuge
- Found by: Kow
- Disclosed: 2023-10-11
- Write-up quality: 6/10
- Original: https://code4rena.com/reports/2023-09-centrifuge#m-03
- Library page: https://bugbountylibrary.com/r/c4%3A2023-09-centrifuge%3AM-03
- Tags: area:web3 domain:web3 impact:dos kind:contest platform:code4rena sev:medium tech:evm tech:solidity technique:source-review vuln:signature-replay

**Target:** ERC20 TrancheToken / Factory.newTrancheToken
**Root cause:** The constructor computes and caches _DOMAIN_SEPARATOR using an empty name string, since name is only set via file() after deployment in Factory.newTrancheToken; the separator is never recomputed while chainid matches deploymentChainId.
**Steps:**
1. Deploy tranche token via `newTrancheToken(...)`: constructor runs `_DOMAIN_SEPARATOR = _calculateDomainSeparator(block.chainid)` with empty name
2. Factory then calls `token.file("name", name)` setting the real name
3. Off-chain signer builds permit signature using the token's actual name in the EIP-712 domain
4. On-chain `permit` recomputes/uses cached separator with empty name; signature mismatch causes revert
**How found:** Code review of constructor ordering: noticed DOMAIN_SEPARATOR cached in constructor while name is set post-deployment by the factory, making the cached domain inconsistent with the token's real EIP-712 domain.
**Insight:** When auditing EIP-2612/permit implementations, check whether DOMAIN_SEPARATOR is cached before all domain fields (name, version) are finalized, especially with factory-deployed tokens where metadata is set after construction.

