LibDiamond.diamondCut()
should check diamondStorage().acceptanceTimes[keccak256(abi.encode(_diamondCut))] != 0
#215
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
resolved
Finding has been patched by sponsor (sponsor pls link to PR containing fix)
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Lines of code
https://github.com/code-423n4/2022-06-connext/blob/main/contracts/contracts/core/connext/libraries/LibDiamond.sol#L100-L103
https://github.com/code-423n4/2022-06-connext/blob/main/contracts/contracts/core/connext/libraries/LibDiamond.sol#L71-L79
https://github.com/code-423n4/2022-06-connext/blob/main/contracts/contracts/core/connext/libraries/LibDiamond.sol#L83-L90
Vulnerability details
Impact
Normally,
diamondStorage().acceptanceTimes[keccak256(abi.encode(_diamondCut))]
will be set inLibDiamond.proposeDiamondCut()
. Then inLibDiamond.diamondCut()
, it checks thatdiamondStorage().acceptanceTimes[keccak256(abi.encode(_diamondCut))] < block.timestamp
.However,
LibDiamond.rescindDiamondCut()
will setdiamondStorage().acceptanceTimes[keccak256(abi.encode(_diamondCut))]
to 0. Which can easily pass the check indiamondCut()
. ButrescindDiamondCut
should rescind_diamondCut
. In conclusion, usingrescindDiamondCut()
can easily bypass the delay time.Moreover, if
proposeDiamondCut()
has never been called, the check for delay time is always passed.Proof of Concept
diamondStorage().acceptanceTimes[keccak256(abi.encode(_diamondCut))]
will be set inLibDiamond.proposeDiamondCut()
https://github.com/code-423n4/2022-06-connext/blob/main/contracts/contracts/core/connext/libraries/LibDiamond.sol#L71-L79
Then in
LibDiamond.diamondCut()
, it checks thatdiamondStorage().acceptanceTimes[keccak256(abi.encode(_diamondCut))] < block.timestamp
https://github.com/code-423n4/2022-06-connext/blob/main/contracts/contracts/core/connext/libraries/LibDiamond.sol#L100-L103
However,
LibDiamond.rescindDiamondCut()
will setdiamondStorage().acceptanceTimes[keccak256(abi.encode(_diamondCut))]
to 0. Which can easily pass the check indiamondCut()
https://github.com/code-423n4/2022-06-connext/blob/main/contracts/contracts/core/connext/libraries/LibDiamond.sol#L83-L90
Tools Used
None
Recommended Mitigation Steps
Add another check in
diamondCut
The text was updated successfully, but these errors were encountered: