Tranche is not compliant with EIP-1404 #311
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-233
low quality report
This report is of especially low quality
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/code-423n4/2023-09-centrifuge/blob/512e7a71ebd9ae76384f837204216f26380c9f91/src/token/Tranche.sol#L35-L39
https://github.com/code-423n4/2023-09-centrifuge/blob/512e7a71ebd9ae76384f837204216f26380c9f91/src/token/Tranche.sol#L72-L73
Vulnerability details
Impact
Tranche Token is defined as: "Extension of ERC20 + ERC1404 for tranche tokens"
It utilizes
RestrictionManager.sol
- which, according to provided documentation is:ERC1404 based contract that checks transfer restrictions
.However, there are some deviations from EIP-1404 in its implementation, which implies, that Tranche Token is not compliant with EIP-1404.
This may cause unexpected behavior due to being non compliant with EIP-1404. Other protocols that integrate with contract may incorrectly assume that it's EIP-1404 compliant - especially that documentation states that it's ERC-1404. EIP-1404 purpose is to create a robust and consistent implementation patterns. Any deviation from this standard will broke the composability and may lead to fund loss. While protocol's implements a contract and describes it as ERC-1404, it should fully conform to EIP-1404 standard.
During the previous Code4rena, lack of EIP compliance were evaluated as High/Medium:
Taking into consideration the current risk of this issue, we've evaluated it as Medium.
The severity evaluation has been prepared with help of Code4rena Severity Categorization:
Since the "hypothetical attack path with stated assumptions" occurs (external protocol which integrates with contract may assume it's EIP-1404 compliant) - the severity has been evaluated as Medium only.
Proof of Concept
According to EIP-1404:
EIP-1404 requires, that
detectTransferRestriction
is being evaluated insidetransfer
andtransferFrom
.However, current implementation of Tranche Tokens evaluates
detectTransferRestriction
also insidemint
:This may cause unexpected behavior and potential fund loss. Other protocols that integrate with contract may incorrectly assume that
detectTransferRestriction
is being called only fortransfer
andtransferFrom
- as EIP-1404 requires. However, this function is also evaluted duringmint()
. Other protocols that integrate with contract may try to callmint()
, without knowing thatdetectTransferRestriction
may revert during mint. Due to lack of EIP-1404 compliance, funds may be lost - since minting won't be possible:mint
, without realizing, thatmint
evalutesdetectTransferRestriction
(even though, EIP-1404 requires thatdetectTransferRestriction
evaluates only fortransferFrom
andtransfer
).detectTransferRestriction
-mint()
fails.Tools Used
Manual code review
Recommended Mitigation Steps
Do not evaluate
detectTransferRestriction
onmint()
call, as - according to EIP-1404, this function should be evaluated ontransfer()
andtransferFrom()
calls. Ifmint()
has the same restrictions astransfer
andtransferFrom
- implement additional modifier - or code them directly insidemint()
.Assessed type
Other
The text was updated successfully, but these errors were encountered: