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

latestRoundData not check result accuracy and freshness #14

Closed
code423n4 opened this issue Jun 4, 2023 · 2 comments
Closed

latestRoundData not check result accuracy and freshness #14

code423n4 opened this issue Jun 4, 2023 · 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-15 edited-by-warden satisfactory satisfies C4 submission criteria; eligible for awards

Comments

@code423n4
Copy link
Contributor

code423n4 commented Jun 4, 2023

Lines of code

https://github.com/code-423n4/2023-06-stader/blob/7566b5a35f32ebd55d3578b8bd05c038feb7d9cc/contracts/StaderOracle.sol#L646-L649

Vulnerability details

Impact

Not check the result's accuracy and freshness of the chainlink oracle, may use incorrect or stale price.

Proof of Concept

        (, int256 totalETHBalanceInInt, , , ) = AggregatorV3Interface(staderConfig.getETHBalancePORFeedProxy())
            .latestRoundData();
        (, int256 totalETHXSupplyInInt, , , ) = AggregatorV3Interface(staderConfig.getETHXSupplyPORFeedProxy())
            .latestRoundData();
        return (uint256(totalETHBalanceInInt), uint256(totalETHXSupplyInInt), block.number);
  • Zero value may be returned when the oracle goes down, no checking. Assuming totalETHBalanceInInt is less than 0, this will simply change to uint256, which causes an error.
  • Oracle may return stale result and the subsequent calculation value is stale and can be used.

Tools Used

Manual Review

Recommended Mitigation Steps

(uint80 roundID, int256 totalETHBalanceInInt, , uint256 timestamp, uint80 answeredInRound) = AggregatorV3Interface(staderConfig.getETHBalancePORFeedProxy()).latestRoundData();
require(totalETHBalanceInInt > 0, "totalETHBalanceInInt <= 0"); 
require(answeredInRound >= roundID, "Stale price");
require(timestamp != 0, "Round not complete");

Assessed type

Oracle

@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 Jun 4, 2023
code423n4 added a commit that referenced this issue Jun 4, 2023
@c4-judge
Copy link
Contributor

c4-judge commented Jun 9, 2023

Picodes marked the issue as duplicate of #15

@c4-judge c4-judge closed this as completed Jun 9, 2023
@c4-judge c4-judge added the satisfactory satisfies C4 submission criteria; eligible for awards label Jul 2, 2023
@c4-judge
Copy link
Contributor

c4-judge commented Jul 2, 2023

Picodes marked the issue as satisfactory

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-15 edited-by-warden satisfactory satisfies C4 submission criteria; eligible for awards
Projects
None yet
Development

No branches or pull requests

2 participants