Loan repayments may revert #124
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
This issue or pull request already exists
Lines of code
https://github.com/code-423n4/2022-06-connext/blob/b4532655071566b33c41eac46e75be29b4a381ed/contracts/contracts/core/connext/libraries/AssetLogic.sol#L347
https://github.com/code-423n4/2022-06-connext/blob/b4532655071566b33c41eac46e75be29b4a381ed/contracts/contracts/core/connext/libraries/AssetLogic.sol#L249
https://github.com/code-423n4/2022-06-connext/blob/b4532655071566b33c41eac46e75be29b4a381ed/contracts/contracts/core/connext/libraries/AssetLogic.sol#L304
https://github.com/code-423n4/2022-06-connext/blob/b4532655071566b33c41eac46e75be29b4a381ed/contracts/contracts/core/connext/facets/PortalFacet.sol#L98
https://github.com/code-423n4/2022-06-connext/blob/b4532655071566b33c41eac46e75be29b4a381ed/contracts/contracts/core/connext/facets/BridgeFacet.sol#L1011
Vulnerability details
Impact
An unexpected revert could cause failures on the part of bridges and portals to repay loans.
Proof of Concept
OpenZeppelin's
safeApprove()
function will revert if the account has already been approved and subsequent calls pass a non-zerovalue
.safeApprove()
is used in one instance in the codebase in theAssetLogic.sol
contract:It is called within a private function
_swapAssetOut()
which is used by the public functionswapFromLocalAssetIfNeededForExactOut()
.This public function is called from the contracts
PortalFacet.sol
andBridgeFacet.sol
.These functions both handle functionality pertaining to loan repayments:
_reconcileProcessPortal()
inBridgeFacet.sol
andrepayAavePortal()
inPortalFacet.sol
.Given that
safeApprove()
will revert when it is called more than once with a non-zerovalue
argument, the use of this function could seriously impact the availability of these features and result in negative financial impacts for users.Tools Used
Reading source code
Recommended Mitigation Steps
Replace calls to
safeApprove()
withsafeIncreaseAllowance()
orsafeDecreaseAllowance()
where appropriate.If this cannot be done, use
safeApprove(0)
if the allowance will be changed.References
The text was updated successfully, but these errors were encountered: