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 oracle lacks proper validation #307

Closed
code423n4 opened this issue Aug 17, 2022 · 2 comments
Closed

Chainlink oracle lacks proper validation #307

code423n4 opened this issue Aug 17, 2022 · 2 comments
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 out of scope

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-08-frax/blob/c4189a3a98b38c8c962c5ea72f1a322fbc2ae45f/src/contracts/FraxlendPairCore.sol#L523-L537

Vulnerability details

Impact

Calls to the Chainlink price oracle via latestRoundData() in FraxlendPairCore.sol use the correct function latestRoundData() per Chainlink's documentation, but lack the recommended validations to ensure that the round is complete and does not return stale data.

Per the following Halborn audit, page 19, the recommended implementation is:

(
roundId,
rawPrice,
,
updateTime,
answeredInRound
) = AggregatorV3Interface(XXXXX).latestRoundData();
require(rawPrice > 0 , "Chainlink price <= 0");
require(updateTime != 0 , "Incomplete round");
require(answeredInRound >= roundId , "Stale price");

Halborn audit, page 19:

https://3405344147-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6bWsvjSvuHlmjaYdDGxA%2Fuploads%2FxvaQXQq7NxRcRQBiGL3J%2FRolla_Finance_Quant_Protocol_Smart_Contract_Security_Audit_Report.pdf?alt=media&token=1d59da93-2e5c-4e53-9de8-a4bb6dba138e

Tools Used

Audit report.

Recommended Mitigation Steps

Add checks for stale data, incomplete round, and 0 price return value. If any of these fail, then the function should revert.

Final Note

Though the Frax documentation lists "outdated answers" as a known issue, I believe that extra validations can alleviate such issue.

@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 Aug 17, 2022
code423n4 added a commit that referenced this issue Aug 17, 2022
@0xA5DF
Copy link

0xA5DF commented Aug 18, 2022

Duplicate of #10 (at least part of it is out of scope)

@amirnader-ghazvini amirnader-ghazvini added the duplicate This issue or pull request already exists label Aug 29, 2022
@amirnader-ghazvini
Copy link
Collaborator

Duplicate of #179

@amirnader-ghazvini amirnader-ghazvini marked this as a duplicate of #179 Aug 29, 2022
@gititGoro gititGoro added invalid This doesn't seem right out of scope labels Sep 30, 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 out of scope
Projects
None yet
Development

No branches or pull requests

4 participants