Borrower should not have payed debt during loan Duration so that lender can call() for auctioning loan purpose.
Then newLender calls auction() and then Collateralization Ratio At LeastOneHundredPercent invariant breaks as they allowing loanAmount > collateralAmount
External pre-conditions
Given example in root cause
Attack Path
Under certain circumstances while calling auction() it breaks the Collateralization Ratio At LeastOneHundredPercent invariant
Let's understand vulnerability through scenario.
Suppose Borrower has accepted a loan from lender in which collateralAmount = 1000 ether and loanAmount = 1000 ether and time duration of loan = 6 months and 10% APY.
Now Borrower doesn't pay loan amount till duration of loan.
Then Lender call() the loan as user didn't pay interest.
Now new lender comes and call auction() to take the loan.
New lender transfers the debt + protocol fee to old lender.
Now new loan gets created with old collateral amount and new loan amount
So the new loan's collateral amount will be 1000 etherand new loan amount would be oldAmount + fee + interest accrued, we can suppose new loan amount would 1100 ether.
So now in the new loan loanAmount > collateralAmount which breaks the Collateralization Ratio At LeastOneHundredPercent invariant.
function _assertCollateralizationRatioAtLeastOneHundredPercent(
uint256 collateralAmount,
uint256 loanAmount
) private pure {
if (collateralAmount < loanAmount) {
revert CollateralizationRatioTooLow();
}
}
Impact
Breaking of Collateralization Ratio At LeastOneHundredPercent main invariant which leads new lender getting under-collaterized loan.
PoC
No response
Mitigation
The Collateralization Ratio At LeastOneHundredPercent invariant should be checked while auction()
smbv-1923
Medium
Breaking of
Collateralization Ratio At LeastOneHundredPercent
invariant duringauction()
Summary
Breaking of
Collateralization Ratio At LeastOneHundredPercent
invariant duringauction()
Root Cause
Collateralization Ratio At LeastOneHundredPercent
invariant.auction()
Internal pre-conditions
call()
for auctioning loan purpose.auction()
and thenCollateralization Ratio At LeastOneHundredPercent
invariant breaks as they allowing loanAmount > collateralAmountExternal pre-conditions
Attack Path
auction()
it breaks theCollateralization Ratio At LeastOneHundredPercent
invariantcollateralAmount = 1000 ether
andloanAmount = 1000 ether
and time duration of loan = 6 months and 10% APY.call()
the loan as user didn't pay interest.auction()
to take the loan.old collateral amount
andnew loan amount
1000 ether
and new loan amount would beoldAmount + fee + interest accrued
, we can suppose new loan amount would1100 ether
.loanAmount > collateralAmount
which breaks theCollateralization Ratio At LeastOneHundredPercent
invariant.Impact
Collateralization Ratio At LeastOneHundredPercent
main invariant which leads new lender getting under-collaterized loan.PoC
No response
Mitigation
Collateralization Ratio At LeastOneHundredPercent
invariant should be checked whileauction()