DOMAIN_SEPARATOR Incorrect signature content #536
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-146
satisfactory
satisfies C4 submission criteria; eligible for awards
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2023-09-centrifuge/blob/512e7a71ebd9ae76384f837204216f26380c9f91/src/token/ERC20.sol#L228
Vulnerability details
Vulnerability details
In the constructor method of
ERC20.SOL
,_DOMAIN_SEPARATOR
will be generated by_calculateDomainSeparator()
and this variable will be used as part of the signature inpermit()
.The main method is as follows.
the content of
_DOMAIN_SEPARATOR
contains the token's nameThe problem is that there are two issues with this
token.name
.token.name
is not initialized in the constructor, it needs to be assigned byfile()
poolManager.updateTrancheTokenMetadata()
can modifytoken.name
later.so
_DOMAIN_SEPARATOR
will contain a blankname
, it's wrong.Because
name
can change, the immutable nature of_DOMAIN_SEPARATOR
is infeasible and it cannot be used as part of a signature.It is recommended not to use
_DOMAIN_SEPARATOR
, but to calculate it in real-time with_calculateDomainSeparator()
.Impact
The user assembles the content of the signature through the
EIP-712
standard, but cannot executepermit()
properly.Proof of Concept
The following code demonstrates this, assembling the signature content as standard, but not the same as
token.DOMAIN_SEPARATOR()
add to Tranche.t.sol
Recommended Mitigation
remove
_DOMAIN_SEPARATOR
, calculate it in real-time with_calculateDomainSeparator()
.Assessed type
Context
The text was updated successfully, but these errors were encountered: