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

Oracle price could not be fresh in ChainlinkInceptionPriceFeed #57

Closed
code423n4 opened this issue Apr 29, 2022 · 1 comment
Closed

Oracle price could not be fresh in ChainlinkInceptionPriceFeed #57

code423n4 opened this issue Apr 29, 2022 · 1 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 duplicate This issue or pull request already exists invalid This doesn't seem right

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-04-mimo/blob/b18670f44d595483df2c0f76d1c57a7bfbfbc083/core/contracts/inception/priceFeed/ChainlinkInceptionPriceFeed.sol#L74-L78

Vulnerability details

Vulnerability

On ChainlinkInceptionPriceFeed, we are using latestRoundData, but there are no validations that the data is not stale.

The current code is:

    (, int256 eurAnswer, , uint256 eurUpdatedAt, ) = _eurOracle.latestRoundData();
    require(eurAnswer > 0, "EUR price data not valid");
    require(block.timestamp - eurUpdatedAt < _PRICE_ORACLE_STALE_THRESHOLD, "EUR price data is stale");

    (, int256 answer, , uint256 assetUpdatedAt, ) = _assetOracle.latestRoundData();
    require(answer > 0, "Price data not valid");
    require(block.timestamp - assetUpdatedAt < _PRICE_ORACLE_STALE_THRESHOLD, "Price data is stale");

But is missing the checks to validate the data is stale

(uint80 roundA, int256 eurAnswer, , uint256 eurUpdatedAt, uint80 answeredInRoundA) = _eurOracle.latestRoundData();
require(eurAnswer > 0, "EUR price data not valid");
require(block.timestamp - eurUpdatedAt < _PRICE_ORACLE_STALE_THRESHOLD, "EUR price data is stale");

require(answeredInRoundA >= roundA, "Stale price");   // <- EXTRA CHECK

This could affect in all the logic, including funds.

Recommendation

Check the round and answeredInRound return.

@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
@Xuefeng-Zhu Xuefeng-Zhu added the duplicate This issue or pull request already exists label May 2, 2022
@Xuefeng-Zhu
Copy link
Collaborator

duplicate with #1

@gzeoneth gzeoneth added the invalid This doesn't seem right label Jun 5, 2022
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 duplicate This issue or pull request already exists invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

4 participants