Skip to content
Smart contracts Audit finding Intermediate

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.

BowTiedWardens Follow

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.get call.
  • Lender cannot call removeCollateral to 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.


The original report as published on Code4rena, by BowTiedWardens. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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

  1. Borrower requests a loan using a malicious oracle.
  2. Lender accepts the loan without knowing the oracle is malicious.
  3. The malicious oracle is configured to never return a liquidating rate.
  4. 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.

More by BowTiedWardens

View all

3 more disclosed reports, best first.

More from AbraNFT contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.