The calculation of ````totalUSDborrowed```` in ````openLoan()```` is not correct
The openLoan function used the wrong variable (isoUSDLoaned instead of isoUSDLoanAndInterest) to calculate total borrowed USD, so an attacker could repay principal but leave interest, then open a new loan without sufficient collateral.
Jeiwan Follow with cccz, CodingNameKiki and 5 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2022-11-isomorph-judging/issues/85
Found by
Jeiwan, cccz, CodingNameKiki, clems4ever, KingNFT, caventa, libratus, HollaDieWaldfee
Summary
The openLoan() function wrongly use isoUSDLoaned to calculate totalUSDborrowed. Attacker can exploit it to bypass security check and loan isoUSD with no enough collateral.
Vulnerability Detail
vulnerability point
function openLoan(
// ...
) external override whenNotPaused
{
//...
uint256 colInUSD = priceCollateralToUSD(currencyKey, _colAmount
+ collateralPosted[_collateralAddress][msg.sender]);
uint256 totalUSDborrowed = _USDborrowed
+ (isoUSDLoaned[_collateralAddress][msg.sender] * virtualPrice)/LOAN_SCALE;
// @audit should be isoUSDLoanAndInterest[_collateralAddress][msg.sender]
require(totalUSDborrowed >= ONE_HUNDRED_DOLLARS, "Loan Requested too small");
uint256 borrowMargin = (totalUSDborrowed * minOpeningMargin) / LOAN_SCALE;
require(colInUSD >= borrowMargin, "Minimum margin not met!");
// ...
}
Attack example: <1>Attacker normally loans and produces 10000 isoUSD interest <2>Attacker repays principle but left interest <3>Attacker open a new 10000 isoUSD loan without providing collateral
Impact
Attacker can loan isoUSD with no enough collateral.
Code Snippet
Tool used
Manual Review
Recommendation
See Vulnerability Detail
Discussion
kree-dotcom
Fixed https://github.com/kree-dotcom/isomorph/commit/3d77c9f706a52eb6312abc711a007ea8431f749b
0x00052
Fixes look good. Vault_Synths now correctly uses isoUSDLoanAndInterest for calculating borrowed USD
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the code used the principal loan amount (isoUSDLoaned) instead of the total loan including interest (isoUSDLoanAndInterest) when calculating the total borrowed USD for the collateral check.
Impact
Attacker can loan isoUSD with no enough collateral.
What the attacker needed
A loan with outstanding interest; ability to repay principal
The fix
The code was fixed to use isoUSDLoanAndInterest instead of isoUSDLoaned when calculating total borrowed USD.
How it was found
- Attacker normally loans and produces 10000 isoUSD interest
- Attacker repays principle but left interest
- Attacker open a new 10000 isoUSD loan without providing collateral
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A smart contract lets people borrow a digital currency (isoUSD) by putting up collateral. The contract checks that the total borrowed amount is not too large compared to the collateral. But it used the wrong number for the borrowed amount, ignoring interest. So someone could borrow, pay back the principal but not the interest, and then borrow again without enough collateral.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.