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

Improper Validation Of Chainlink's latestRoundData() Function #123

Closed
code423n4 opened this issue Feb 23, 2022 · 1 comment
Closed

Improper Validation Of Chainlink's latestRoundData() Function #123

code423n4 opened this issue Feb 23, 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

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-02-hubble/blob/main/contracts/Oracle.sol#L33
https://github.com/code-423n4/2022-02-hubble/blob/main/contracts/Oracle.sol#L115

Vulnerability details

Impact

The calls to the latestRoundData() function do not validate the output of the Chainlink oracle query. As a result, it is possible to use stale results when returning the TWAP price. latestRoundData() is able to ensure the round is complete and has returned a valid/expected price by validating additional round data. This is documented here. However, there are some missing validations that can be improve upon the existing implementation.

Proof of Concept

https://github.com/code-423n4/2022-02-hubble/blob/main/contracts/Oracle.sol#L33
https://github.com/code-423n4/2022-02-hubble/blob/main/contracts/Oracle.sol#L115

Tools Used

Manual code review.
Chainlink best practices.

Recommended Mitigation Steps

Consider performing proper validation of Chainlink's latestRoundData() function. This can be updated or adapted to match the following code snippet:

(
uint80 roundID,
int256 oraclePrice,
,
uint256 updateTime,
uint80 answeredInRound
) = AggregatorV2V3Interface(priceOracle).latestRoundData();
require(
answeredInRound >= roundID,
"Hubble: Chainlink Price Stale"
);
require(oraclePrice > 0, "Hubble: Chainlink Malfunction");
require(updateTime != 0, "Hubble: Incomplete round");
@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 Feb 23, 2022
code423n4 added a commit that referenced this issue Feb 23, 2022
@atvanguard
Copy link
Collaborator

Duplicate of #46

@atvanguard atvanguard marked this as a duplicate of #46 Feb 24, 2022
@atvanguard atvanguard added the duplicate This issue or pull request already exists label Feb 24, 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
Projects
None yet
Development

No branches or pull requests

2 participants