DOMAIN_SEPARATOR
of ERC20
is incorrectly calculated and used
#247
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/main/src/token/ERC20.sol#L48
https://github.com/code-423n4/2023-09-centrifuge/blob/main/src/token/ERC20.sol#L71
Vulnerability details
DOMAIN_SEPARATOR
ofERC20
is incorrectly calculated and usedImpact
permit()
ofERC20
doesn't work as intented, implementation of EIP-1271_isValidSignature()
will use incorrect digestDescription
_DOMAIN_SEPARATOR
ofERC20
is incorrectly calculated._DOMAIN_SEPARATOR
is used asDOMAIN_SEPARATOR
inpermit()
and passed in the_isValidSignature()
function.Since
block.chainId
will always equaldeploymentChainId
as we see in the constructor: this means inpermit()
always the incorrectly calculated_DOMAIN_SEPARATOR
will be used since the expressionblock.chainid == deploymentChainId ? _DOMAIN_SEPARATOR
is always true.src/token/ERC.20.sol
-constructor
src/token/ERC20.sol
-_calculateDomainSeparator()
The problem is that the
_calculateDomainSeparator()
will use the emptyname
when it is not yet set in the constructor, only later viafile()
. Even after thename
was set, the incorrectly calculated_DOMAIN_SEPARATOR
(set in constructor) remains to be used.Tools Used
Manual review
Recommended Mitigation Steps
Set
name
in the constructor before calculating_DOMAIN_SEPARATOR
via_calculateDomainSeparator()
. Consider settingsymbol
in the constructor as well for convenience.Assessed type
Timing
The text was updated successfully, but these errors were encountered: