You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 3, 2024. It is now read-only.
sherlock-admin opened this issue
Aug 28, 2023
· 0 comments
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelMediumA valid Medium severity issueRewardA payout will be made for this issue
Where loanID specifices the index of the existing loan. Here we can propose a new interest rate, loanToCollateral & duration.
The borrower can review the new terms and callrollLoan() to accept the roll as long as the block.timestamp > loan.expiry and loan.request.active == true (which is set to true when proposing new roll terms).
functionrollLoan(uint256loanID_)external{Loanmemoryloan=loans[loanID_];if(block.timestamp>loan.expiry)revertDefault();if(!loan.request.active)revertNotRollable();// Check whether rolling the loan requires pledging more collateral or not (if there was a previous repayment).uint256newCollateral=newCollateralFor(loanID_);uint256newDebt=interestFor(loan.amount,loan.request.interest,loan.request.duration);// Update memory accordingly.loan.amount+=newDebt;loan.collateral+=newCollateral;loan.expiry+=loan.request.duration;loan.request.active=false;// Save updated loan info in storage.loans[loanID_]=loan;if(newCollateral>0){collateral().safeTransferFrom(msg.sender,address(this),newCollateral);}// If necessary, trigger lender callback.if(loan.callback)CoolerCallback(loan.lender).onRoll(loanID_,newDebt,newCollateral);}
The issue stems from the fact that the lender (attacker) can front-run ther borrower's call to rollLoan() and change the conditions for the loan to a much higher interest rate than first proposed, forcing the borrower into a bad loan. Since we are not proposing a new loanID but rather overwriting data on the existing one, the borrower's call goes through and he accepts the malicious attack conditions. Since there is no cap on interest rate this is especially problematic.
Order of attack:
A cooler is generated for e.g. a USDC/USDT debt/collateral pair.
Borrower requests a loan and malicious lender clears the request.
Some time passes and malicious lender proposes new, favorable conditions with low interest rate and extended loan duration.
Borrower is happy to agree on the new conditions and calls rollLoan().
Malicious lender monitors the mempool and front-runs the borrower, changing the loan conditions to a much higher interest rate for the same loanID.
Borrower's transaction goes through and he accepts the new malicious loan conditions.
Borrower is stuck with bad loan and might be forced to default on it.
Impact
Borrower is forced to accept bad conditions for his loan and cannot do anything about it, might also lead to the loan defaulting.
One way to solve this would be to implement a sort of time-lock mechanism that does not allow the lender to change the loan conditions for a set period of time after proposing new ones once. Although it would still be technically possible if the borrower is slow to accept the new terms, it makes it much less likely.
sherlock-admin2
changed the title
Rare Sangria Troll - Front-Running rollLoan With newTermsForRoll Forces High Interest Rate on Loan
cats - Front-Running rollLoan With newTermsForRoll Forces High Interest Rate on Loan
Sep 12, 2023
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelMediumA valid Medium severity issueRewardA payout will be made for this issue
cats
high
Front-Running rollLoan With newTermsForRoll Forces High Interest Rate on Loan
Summary
Vulnerability related to front-running a borrower's transaction and forcing him to take on a high interest rate.
Vulnerability Detail
The function
provideNewTermsForRoll()
inCooler.sol
gives us the opportunity to propose new terms for an existingloanID
:Where
loanID
specifices the index of the existing loan. Here we can propose a new interest rate, loanToCollateral & duration.The borrower can review the new terms and call
rollLoan()
to accept the roll as long as theblock.timestamp > loan.expiry
andloan.request.active == true
(which is set to true when proposing new roll terms).The issue stems from the fact that the lender (attacker) can front-run ther borrower's call to
rollLoan()
and change the conditions for the loan to a much higher interest rate than first proposed, forcing the borrower into a bad loan. Since we are not proposing a newloanID
but rather overwriting data on the existing one, the borrower's call goes through and he accepts the malicious attack conditions. Since there is no cap on interest rate this is especially problematic.Order of attack:
rollLoan()
.loanID
.Impact
Borrower is forced to accept bad conditions for his loan and cannot do anything about it, might also lead to the loan defaulting.
Code Snippet
provideNewTermsForRoll()
rollLoan()
Tool used
VSCode, Manual Review
Recommendation
One way to solve this would be to implement a sort of time-lock mechanism that does not allow the lender to change the loan conditions for a set period of time after proposing new ones once. Although it would still be technically possible if the borrower is slow to accept the new terms, it makes it much less likely.
Duplicate of #243
The text was updated successfully, but these errors were encountered: