Skip to content
Crypto Audit finding Intermediate

Cached DOMAIN_SEPARATOR is incorrect for tranche tokens potentially breaking permit integrations

The cached EIP-712 domain separator for tranche tokens is computed in the constructor before the token name is set, so it uses an empty name. Any permit signature built with the real token name will not match, causing permit calls to revert.

Kow Follow with 0xRobsol, codegpt and 8 others

Originally disclosed on Code4rena

Submitted by Kow, also found by 0xRobsol, codegpt, 0xkazim, josephdara, Aymen0909, 0xpiken (1, 2), bin2chen, nmirchev8, rvierdiiev (1, 2), lsaudit (1, 2), 0xfuje, gumgumzum, T1MOH, and ravikiranweb3 (1, 2, 3)

Attempts to interact with tranche tokens via permit may always revert.

Proof of Concept

When new tranche tokens are deployed, the initial DOMAIN_SEPARATOR is calculated and cached in the constructor. https://github.com/code-423n4/2023-09-centrifuge/blob/512e7a71ebd9ae76384f837204216f26380c9f91/src/token/ERC20.sol#L42-L49

    constructor(uint8 decimals_) {
        ...
        deploymentChainId = block.chainid;
        _DOMAIN_SEPARATOR = _calculateDomainSeparator(block.chainid);
    }

This uses an empty string since name is only set after deployment. https://github.com/code-423n4/2023-09-centrifuge/blob/512e7a71ebd9ae76384f837204216f26380c9f91/src/util/Factory.sol#L81-L109

    function newTrancheToken(
        uint64 poolId,
        bytes16 trancheId,
        string memory name,
        string memory symbol,
        uint8 decimals,
        address[] calldata trancheTokenWards,
        address[] calldata restrictionManagerWards
    ) public auth returns (address) {
        ...
        TrancheToken token = new TrancheToken{salt: salt}(decimals);

        token.file("name", name);
        ...
    }

Consequently, the domain separator is incorrect (when block.chainid == deploymentChainId where the domain separator is not recalculated) and will cause reverts when signatures for permit are attempted to be constructed using the tranche token’s name (which will not be empty).

It should also be noted that the tranche token name could be changed by a call to updateTranchTokenMetadata which may also introduce complications with the domain separator.

Recommended Mitigation Steps

Consider setting the name in the constructor before the cached domain separator is calculated.

hieronx (Centrifuge) confirmed and commented:

Mitigated in https://github.com/centrifuge/liquidity-pools/pull/142


The original report as published on Code4rena, by Kow. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The domain separator is cached in the constructor before the token name is assigned, so it is calculated with an empty name.

Impact

Permit interactions with tranche tokens may always revert, and later name changes could cause further complications.

What the attacker needed

Tranche token deployed via factory; permit used with the token name

The fix

The name should be set in the constructor before the cached domain separator is calculated; the project says it was mitigated in a later pull request.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A permit is a way to approve token spending with a signature instead of a separate transaction. The signature is tied to a domain separator, a value derived from the token's name and chain. Here the separator was calculated before the name was set, so it does not match the real token and signatures fail.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

More by Kow

View all

8 more disclosed reports, best first.

More from Centrifuge

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.