Skip to content
Audit finding Intermediate

The return value success of the get function of the INFTOracle interface is not checked

The NFTPairWithOracle contract calls the INFTOracle.get function but ignores the returned success flag. If the oracle call fails, the contract may use stale price data, potentially leading to asset loss.

cccz Follow

Originally disclosed on Code4rena

Submitted by cccz, also found by Ruhum, catchup, IllIllI, WatchPug, berndartmueller, plotchy, antonttc, hyh, and 0xf15ers

    function get(address pair, uint256 tokenId) external returns (bool success, uint256 rate);

The get function of the INFTOracle interface returns two values, but the success value is not checked when used in the NFTPairWithOracle contract. When success is false, NFTOracle may return stale data.

Proof of Concept

https://github.com/code-423n4/2022-04-abranft/blob/5cd4edc3298c05748e952f8a8c93e42f930a78c2/contracts/interfaces/INFTOracle.sol#L10-L10

https://github.com/code-423n4/2022-04-abranft/blob/5cd4edc3298c05748e952f8a8c93e42f930a78c2/contracts/NFTPairWithOracle.sol#L287-L287

https://github.com/code-423n4/2022-04-abranft/blob/5cd4edc3298c05748e952f8a8c93e42f930a78c2/contracts/NFTPairWithOracle.sol#L321-L321

Recommended Mitigation Steps

(bool success, uint256 rate) = loanParams.oracle.get(address(this), tokenId);
require(success);

cryptolyndon (AbraNFT) confirmed and commented:

Agreed, and the first report of this issue.

0xean (judge) increased severity to High and commented:

I am upgrading this to High severity.

This is a direct path to assets being lost.

3 — High: Assets can be stolen/lost/compromised directly (or indirectly if there is a valid attack path that does not have hand-wavy hypotheticals).


The original report as published on Code4rena, by cccz. 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 contract does not check the boolean success value returned by the oracle's get function before using the rate.

Impact

If the oracle call fails, the contract may use stale price data, which could lead to assets being lost or stolen.

What the attacker needed

Oracle call returns success=false

The fix

The contract should check the success flag and revert if it is false, as shown in the recommended mitigation.

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 asks an oracle for a price. The oracle replies with a success flag and a price. The contract forgets to check the success flag, so it might use an old price even when the oracle failed. That could let someone trade at a wrong price and steal funds.

More by cccz

View all

104 more disclosed reports, best first.

More from AbraNFT contest

View all

The newest disclosed reports for this program.

Similar reports

Same bug class and techniques, clearest first.