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

SaharDevep - Stale or incorrect price return from Chainlink's latestRoundData #766

Closed
sherlock-admin opened this issue May 24, 2023 · 0 comments
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

SaharDevep

medium

Stale or incorrect price return from Chainlink's latestRoundData

SaharDevep

Medium

Stale or incorrect collateral price return from Chainlink's latestRoundData

Summary

latestRoundData is used, but there is no check to see if the returned value indicates stale data.

Vulnerability Detail

in StableOracleDAI.sol:
    (, int256 price, , , ) = priceFeedDAIETH.latestRoundData();
        // @audit Not enough checks
        return
            (wethPriceUSD * 1e18) /
            ((DAIWethPrice + uint256(price) * 1e10) / 2);
in StableOracleWBTC.sol:
        // @audit Not enough checks
        (, int256 price, , , ) = priceFeed.latestRoundData();
        // chainlink price data is 8 decimals for WETH/USD
        return uint256(price) * 1e10;
in StableOracleWETH.sol:
        // @audit Not enough checks
        (, int256 price, , , ) = priceFeed.latestRoundData();
        // chainlink price data is 8 decimals for WETH/USD
        return uint256(price) * 1e10;

Impact

This could lead to stale prices according to the Chainlink documentation:
https://docs.chain.link/data-feeds/price-feeds/historical-data
Related report:
sherlock-audit/2023-02-blueberry-judging#94

Code Snippet

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

Tool used

Manual Review

Recommendation

Consider adding these checks:

        (uint80 roundID, int256 price, uint256 timestamp, uint256 updatedAt, ) = priceFeed.latestRoundData();
        require(updatedAt >= roundID, "Stale price");
        require(timestamp != 0,"Round not complete");
        require(answer > 0,"Chainlink answer reporting 0");

        if (updatedAt < block.timestamp - maxDelayTime)
            revert();

        // now return price

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