Repaying AAVE Loan in _local
rather than adopted
asset
#103
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/facets/PortalFacet.sol#L80
Vulnerability details
Impact
When repaying the AAVE Portal in
repayAavePortal()
the_local
asset is used to repay the loan in_backLoan()
rather than theadopted
asset. This is likely to cause issues in production when actually repaying loans if the asset/token being repayed to AAVE is not the same as the asset/token that was borrowed.Proof of Concept
The comment on
L93
ofPortalFacet.sol
states;The swap is executed on
L98
in the call toAssetLogic.swapFromLocalAssetIfNeededForExactOut()
however the return valueadopted
is never used (it's an unused local variable). The full function is shown below;The balance of the
_local
token is reduced but instead of theadopted
token being passed to_backLoan()
in L112 the_local
token is used.Tools Used
Vim
Recommended Mitigation Steps
To be consistent with the comments in the
repayAavePortal()
functionadopted
should be passed to_backLoan
so that the loan is repayed in the appropriate token.Remove the reference to
_local
in the_backLoan()
function and replace it withadopted
so it reads;_backLoan(adopted, _backingAmount, _feeAmount, _transferId);
The text was updated successfully, but these errors were encountered: