Critical Oracle Manipulation Risk by Lender
The lender could replace the price oracle on an outstanding loan because the parameter update check did not compare the new oracle with the current one. A malicious lender could then feed a manipulated low price so the contract allowed them to seize collateral that had risen in value above the amount owed.
Submitted by 0x1337, also found by catchup, cccz, kenzo, GimelSec, BowTiedWardens, gzeon, horsefacts, and hyh
The intended use of the Oracle is to protect the lender from a drop in the borrower’s collateral value. If the collateral value goes up significantly and higher than borrowed amount + interest, the lender should not be able to seize the collateral at the expense of the borrower. However, in the NFTPairWithOracle contract, the lender could change the Oracle once a loan is outstanding, and therefore seize the collateral at the expense of the borrower, if the actual value of the collateral has increased significantly. This is a critical risk because borrowers asset could be lost to malicious lenders.
Proof of Concept
In NFTPairWithOracle, the params are set by the borrower when they call requestLoan(), including the Oracle used. Once a lender agrees with the parameters and calls the lend() function, the loan.status changes to LOAN_OUTSTANDING.
Then, the lender can call the updateLoanParams() function and pass in its own params including the Oracle used. The require statement from line 205 to 211 does not check if params.oracle and cur.oracle are the same. A malicious lender could pass in his own oracle after the loan becomes outstanding, and the change would be reflected in line 221.
In a situation where the actual value of the collateral has gone up by a lot, exceeding the amount the lender is owed (principal + interest), the lender would have an incentive to seize the collateral. If the Oracle is not tampered with, lender should not be able to do this, because line 288 should fail. But a lender could freely change Oracle once the loan is outstanding, then a tampered Oracle could produce a very low rate in line 287 such that line 288 would pass, allowing the lender to seize the collateral, hurting the borrower.
Recommended Mitigation Steps
Once a loan is agreed to, the oracle used should not change. I’d recommend adding a check in the require statement in line 205 - 211 that params.oracle == cur.oracle
cryptolyndon (AbraNFT) confirmed and commented:
Confirmed, this is bad. First report of this particular exploit.
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
The parameter update function did not require the new oracle address to equal the existing one, so the lender could substitute the oracle after the loan became outstanding.
Impact
A malicious lender could seize collateral whose real value had risen well above the amount owed, causing a loss to the borrower.
What the attacker needed
A loan becomes outstanding; lender is malicious
The fix
The oracle should be locked once a loan is agreed, by requiring in the parameter update check that the new oracle equals the current one.
How it was found
- The borrower calls requestLoan with parameters that include the oracle to be used.
- The lender calls lend, and the loan status becomes outstanding.
- The lender calls updateLoanParams with their own parameters containing a different oracle.
- The tampered oracle reports a very low rate, so the check at line 288 passes.
- The lender seizes the collateral even though its real value exceeds principal plus interest.
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 loan contract uses a price feed, called an oracle, to decide how much collateral is worth. The borrower picks that price feed when asking for a loan, but the lender was allowed to swap it for a different one after the loan started. A dishonest lender could point to a fake price feed that reports a very low value, letting them take the collateral even though it was actually worth more than the debt.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.