Avoidance of Liquidation Via Malicious Oracle
A borrower could supply a malicious oracle when requesting a loan, and the lender had no way to verify or reject it. The malicious oracle would never return a liquidating rate, allowing the borrower to avoid liquidation.
Originally disclosed on Code4rena
Submitted by BowTiedWardens, also found by gzeon, and hyh
Issue: Arbitrary oracles are permitted on construction of loans, and there is no check that the lender agrees to the used oracle.
Consequences: A borrower who requests a loan with a malicious oracle can avoid legitimate liquidation.
Proof of Concept
- Borrower requests loan with an malicious oracle
- Lender accepts loan unknowingly
- Borrowers’s bad oracle is set to never return a liquidating rate on
oracle.getcall. - Lender cannot call
removeCollateralto liquidate the NFT when it should be allowed, as it will fail the check on L288 - To liquidate the NFT, the lender would have to whitehat along the lines of H-01, by atomically updating to an honest oracle and calling
removeCollateral.
Mitigations
- Add
require(params.oracle == accepted.oracle)as a condition in_lend - Consider only allowing whitelisted oracles, to avoid injection of malicious oracles at the initial loan request stage
cryptolyndon (AbraNFT) confirmed and commented:
Oracle not compared to lender agreed value: confirmed, and I think this is the first time I’ve seen this particular vulnerability pointed out. Not marking the entire issue as a duplicate for that reason.
Oracle not checked on loan request: Not an issue, first reported in #62.
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 loan contract did not verify that the oracle supplied by the borrower matched the oracle the lender had accepted.
Impact
A borrower could avoid legitimate liquidation, but the lender might still recover by atomically switching to an honest oracle and calling removeCollateral, as described in a related finding.
What the attacker needed
Borrower can request a loan; lender accepts without checking oracle; malicious oracle contract deployed
The fix
The contract should require that the oracle in the loan request matches the oracle the lender accepted, and should consider whitelisting oracles.
How it was found
- Borrower requests a loan using a malicious oracle.
- Lender accepts the loan without knowing the oracle is malicious.
- The malicious oracle is configured to never return a liquidating rate.
- The lender cannot call removeCollateral to liquidate because the oracle check fails.
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.
In a lending system, an oracle is a service that reports the current price of an asset. If a borrower can choose which oracle the system trusts, they can pick one that lies and says their collateral is always valuable, so they never get liquidated. This report shows that the loan contract accepted any oracle the borrower provided without checking it against what the lender agreed to.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.