Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

Proxy - D3Oracle will return the wrong price if the Chainlink aggregator returns price outside min/max range #129

Open
sherlock-admin opened this issue Jul 1, 2023 · 3 comments
Labels
Has Duplicates A valid issue with 1+ other issues describing the same vulnerability Medium A valid Medium severity issue Reward A payout will be made for this issue Won't Fix The sponsor confirmed this issue will not be fixed

Comments

@sherlock-admin
Copy link
Contributor

Proxy

medium

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

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

(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

 require(price >= minAnswer && price <= maxAnswer, "invalid price");
@Attens1423
Copy link

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

@0xffff11
Copy link
Collaborator

@Attens1423
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Has Duplicates A valid issue with 1+ other issues describing the same vulnerability Medium A valid Medium severity issue Reward A payout will be made for this issue Won't Fix The sponsor confirmed this issue will not be fixed
Projects
None yet
Development

No branches or pull requests

4 participants