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

0xPkhatri - Chainlink Oracle priceFeed Data May Return Stale Prices #783

Closed
sherlock-admin opened this issue May 24, 2023 · 0 comments
Closed
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A valid Medium severity issue Reward A payout will be made for this issue

Comments

@sherlock-admin
Copy link
Contributor

sherlock-admin commented May 24, 2023

0xPkhatri

medium

Chainlink Oracle priceFeed Data May Return Stale Prices

Summary

The StableOracleWBTC, StableOracleWETH, and StableOracleDAI contract does not sufficiently validate the Chainlink oracle data feed for stale prices. If stale prices are used, it could lead to inaccuracies in calculations depending on the price.

Vulnerability Detail

In the StableOracle contract, the getPriceUSD function retrieves the price of Token in USD using Chainlink's latestRoundData function, without validating the freshness of the returned price. It simply takes the price from the returned data, ignoring other returned parameters such as roundId and answeredInRound. According to Chainlink's documentation, comparing answeredInRound against the current roundId can help determine whether the returned answer is fresh or not. also it not check price > 0.

    function getPriceUSD() external view override returns (uint256) {
        //(uint80 roundID, int256 price, uint256 startedAt, uint256 timeStamp, uint80 answeredInRound) = priceFeed.latestRoundData();
        (, int256 price, , , ) = priceFeed.latestRoundData();
        // chainlink price data is 8 decimals for WETH/USD
        return uint256(price) * 1e10;
    }

Impact

The failure to validate the freshness of the price may result in the usage of stale prices, leading to incorrect calculations where price matters.

Code Snippet

https://github.com/sherlock-audit/2023-05-USSD/blob/main/ussd-contracts/contracts/oracles/StableOracleDAI.sol#L48
https://github.com/sherlock-audit/2023-05-USSD/blob/main/ussd-contracts/contracts/oracles/StableOracleWETH.sol#L23
https://github.com/sherlock-audit/2023-05-USSD/blob/main/ussd-contracts/contracts/oracles/StableOracleWBTC.sol#L23

Tool used

Manual Review

Recommendation

please verify whether the price is fresh or stale.

Duplicate of #31

@github-actions github-actions bot closed this as completed Jun 5, 2023
@github-actions github-actions bot added Medium A valid Medium severity issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels Jun 5, 2023
@sherlock-admin sherlock-admin added the Reward A payout will be made for this issue label Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A valid Medium severity issue Reward A payout will be made for this issue
Projects
None yet
Development

No branches or pull requests

1 participant