Skip to content
Audit finding Intermediate

D3Oracle will return the wrong price if the Chainlink aggregator returns price outside min/max range

0xdice91 Follow with BugHunter101, MohammedRizwan and 4 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-06-dodo-judging/issues/129

Found by

0xdice91, BugHunter101, MohammedRizwan, PRAISE, Proxy, dirk_y, kutugu

Summary

Chainlink oracles have a min and max price that they return. If the price goes below the minimum price the oracle will not return the correct price but only the min price. Same goes for the other extremity.

Vulnerability Detail

Both getPrice() and getOriginalPrice() only check price > 0 not are they within the correct range

Solidity
(uint80 roundID, int256 price,, uint256 updatedAt, uint80 answeredInRound) = priceFeed.latestRoundData();
require(price > 0, "Chainlink: Incorrect Price");
require(block.timestamp - updatedAt < priceSources[token].heartBeat, "Chainlink: Stale Price");
require(answeredInRound >= roundID, "Chainlink: Stale Price");

Impact

The wrong price may be returned in the event of a market crash. The functions with the issue are used in D3VaultFunding.sol, D3VaultLiquidation.sol and D3UserQuota.sol

Code Snippet

Tool used

Manual Review

Recommendation

Check the latest answer against reasonable limits and/or revert in case you get a bad price

Solidity
 require(price >= minAnswer && price <= maxAnswer, "invalid price");

Discussion

Attens1423

How can we get minPrice and maxPrice from oracle contract? Could you give us a more detailed procession?

0xffff11

https://docs.chain.link/data-feeds#check-the-latest-answer-against-reasonable-limits @Attens1423

Attens1423

We understand this doc. If you could offer a code example, including how to get minPrice and maxPrice from code, we would appreciate it

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

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is known

A medium-severity security bug in DODO V3 update. Sherlock made it public on 25 July 2023. Found in the 89 audit contest (finding M-5), also found by 6 other wardens.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

More by 0xdice91

View all

5 more disclosed reports, best first.

More from DODO V3 update

View all

The newest disclosed reports for this program.

Similar reports

Same bug class and techniques, clearest first.