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

peanuts - Chainlink oracle's price check may be insufficient validated #430

Closed
sherlock-admin opened this issue Mar 27, 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 Mar 27, 2023

peanuts

medium

Chainlink oracle's price check may be insufficient validated

Summary

Chainlink oracle's price check may be insufficient.

Vulnerability Detail

The function getLatestPrice in ControllerPeggedAssetV2.sol checks for round completeness and price, but does not check for staleness of price. (uint256 updatedAt variable)

        (uint80 roundID, int256 price, , , uint80 answeredInRound) = priceFeed
            .latestRoundData();
        uint256 decimals = priceFeed.decimals();

...
...

        if (price <= 0) revert OraclePriceZero();


        if (answeredInRound < roundID) revert RoundIDOutdated();


        return price;

The above checks for the staleness of the sequencer, not the staleness of price.

/// @--audit this checks for the staleness of the sequencer
        uint256 timeSinceUp = block.timestamp - startedAt;
        if (timeSinceUp <= GRACE_PERIOD_TIME) {
            revert GracePeriodNotOver();
        }

Impact

Oracle may return a stale price.

Code Snippet

https://github.com/sherlock-audit/2023-03-Y2K/blob/main/Earthquake/src/v2/Controllers/ControllerPeggedAssetV2.sol#L296-L317

Tool used

Manual Review

Recommendation

Recommend checking for the updated price as well

+        (uint80 roundID, int256 price, , uint256 updatedAt, uint80 answeredInRound) = priceFeed
            .latestRoundData();
        uint256 decimals = priceFeed.decimals();

...
...

        if (price <= 0) revert OraclePriceZero();

  
        if (answeredInRound < roundID) revert RoundIDOutdated();

+     if(block.timestamp - updatedAt > GRACE_PERIOD_TIME) revert PriceOutdated();
        return price;

Duplicate of #70

@github-actions github-actions bot closed this as completed Apr 3, 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 Apr 3, 2023
@sherlock-admin sherlock-admin added the Reward A payout will be made for this issue label Apr 11, 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