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 price in FraxlendPairCore.sol #244

Closed
code423n4 opened this issue Aug 17, 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 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#L524
https://github.com/code-423n4/2022-08-frax/blob/c4189a3a98b38c8c962c5ea72f1a322fbc2ae45f/src/contracts/FraxlendPairCore.sol#L532

Vulnerability details

Proof of Concept

(, int256 _answer, , , ) = AggregatorV3Interface(oracleMultiply).latestRoundData();
            if (_answer <= 0) {
                revert OracleLTEZero(oracleMultiply);
     }

When calling latestRoundData the code does check if the price is not less than or equal to zero, but it doesn’t check if the round is incomplete or the price is stale. The issue is for both oracleMultiply and oracleDivide.

Impact

The exchangeRate is a core part of the protocol and using a stale price can result in the protocol not allowing a liquidator to liquidate a position yet, even though the price is crashing and a borrower is insolvent, which will result in a loss of capital.

Recommendation

Change the latestRoundData logic to the following (you can use custom errors instead require statements as well):

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

Change the code exactly the same way for the oracleDivide latestRoundData() call.

@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
@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

3 participants