ERC20.permit() may not work because wrong calculation #345
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
Vulnerability details
Impact
Due to wrong calculation of
_DOMAIN_SEPARATOR
,ERC20.permit()
may not verify signature signed by signer. The design is supposed to support offline token approving but can not work as expected.Proof of Concept
When calculating
_DOMAIN_SEPARATOR
during tranche token deployment, the fieldname
is also included, but the value is not set inconstructor()
. It only has correct value whenERC20.file("name", name)
is called.From the user's perspective, they will create signature following EIP-2612, the name of the tranche token will be used for
_DOMAIN_SEPARATOR
calculation and the result will be different from the value stored in tranche token smart contract,ERC20.permit()
will always be reverted because of this incorrect calculation.Tools Used
Manual review
Recommended Mitigation Steps
Pass
name
inERC20.constructor()
other than assigning it's value throughERC20.file("name", name)
:Assessed type
Other
The text was updated successfully, but these errors were encountered: