Closed code423n4 closed 1 year ago
GalloDaSballo marked the issue as primary issue
miladpiri marked the issue as disagree with severity
This issue does not have bad impact and can not adversly impact on the user or protocol. Moreover, the probablity is very low, because the facet and it's selectors are added in the diamondCut, so there are a lot of middle checks that prevents such issue. QA is a fair severity!
miladpiri marked the issue as sponsor acknowledged
Agree that the submission is missing a lossy impact, will downgrade to QA - Low
L
Lines of code
https://github.com/code-423n4/2022-10-zksync/blob/main/ethereum/contracts/zksync/DiamondProxy.sol#L19-L54
Vulnerability details
Impact
Not checking if the delegated contract exists can result silent failures for the caller, causing unexpected contract funtionality and break third-party integrations.
Proof of Concept
DiamondProxy
fallback usesdelegatecall
and does not check for contract existancehttps://github.com/code-423n4/2022-10-zksync/blob/main/ethereum/contracts/zksync/DiamondProxy.sol#L19-L54
Trail of bits has an article about this issue (search for "No contract existence check").
Note that OpenZeppelin checks for contract existance for Initializable inside proxy (not diamond).
https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/proxy/utils/Initializable.sol#L86
https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Address.sol#L41
Recommended Mitigation Steps
Since the project is adding an in-house implementation of the Diamond Standard, consider adding a check for contract existance. E.g.