Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chainlink's latestRoundData might return stale or incorrect results #53

Closed
code423n4 opened this issue Apr 29, 2022 · 1 comment
Closed
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working invalid This doesn't seem right sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-04-mimo/blob/b18670f44d595483df2c0f76d1c57a7bfbfbc083/core/contracts/core/PriceFeed.sol#L66-L66

Vulnerability details

Impact

In many contracts , we are using latestRoundData, but there is no check if the return value indicates stale data.

This could lead to stale prices according to the Chainlink documentation:

https://docs.chain.link/docs/historical-price-data/#historical-rounds
https://docs.chain.link/docs/faq/#how-can-i-check-if-the-answer-to-a-round-is-being-carried-over-from-a-previous-round

Proof of Concept

https://github.com/code-423n4/2022-04-mimo/blob/b18670f44d595483df2c0f76d1c57a7bfbfbc083/core/contracts/core/PriceFeed.sol#L66-L66
https://github.com/code-423n4/2022-04-mimo/blob/b18670f44d595483df2c0f76d1c57a7bfbfbc083/core/contracts/core/PriceFeed.sol#L70-L70
https://github.com/code-423n4/2022-04-mimo/blob/b18670f44d595483df2c0f76d1c57a7bfbfbc083/core/contracts/inception/priceFeed/ChainlinkInceptionPriceFeed.sol#L74-L74
https://github.com/code-423n4/2022-04-mimo/blob/b18670f44d595483df2c0f76d1c57a7bfbfbc083/core/contracts/inception/priceFeed/ChainlinkInceptionPriceFeed.sol#L78-L78
https://github.com/code-423n4/2022-04-mimo/blob/b18670f44d595483df2c0f76d1c57a7bfbfbc083/core/contracts/oracles/BalancerV2LPOracle.sol#L101-L102
https://github.com/code-423n4/2022-04-mimo/blob/b18670f44d595483df2c0f76d1c57a7bfbfbc083/core/contracts/oracles/GUniLPOracle.sol#L103-L104

Tools Used

None

Recommended Mitigation Steps

For example

      (uint80 roundID, int256 answer, , uint256 timestamp, uint80 answeredInRound) = eurOracle.latestRoundData();
      require(answeredInRound >= roundID, "Stale price");
      require(timestamp != 0,"Round not complete");
      require(answer > 0,"Chainlink answer reporting 0");
@code423n4 code423n4 added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working labels Apr 29, 2022
code423n4 added a commit that referenced this issue Apr 29, 2022
@m19
Copy link
Collaborator

m19 commented May 5, 2022

We disagree because of the following reasons:

  • In all the PriceFeed contracts staleness is correctly checked using the updatedAt field. Checking for both roundID and answeredInRound is redundant because answeredInRound and roundId are always the same in the latest Chainlink agggregators contracts. This is a duplicate of Should check return data from chainlink aggregators #1
  • In the Oracle contracts it's intended to return the oldest the updatedAt because the consumer of an Oracle contract can then decide what to do with it, different contracts might have different requirements on what is considered stale, as the Oracle contracts are consumed by our PriceFeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working invalid This doesn't seem right sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue
Projects
None yet
Development

No branches or pull requests

3 participants