Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

ast3ros - Result from Chainlink oracle price is not checked for validity #127

Closed
sherlock-admin opened this issue Aug 15, 2023 · 1 comment
Labels
Non-Reward This issue will not receive a payout

Comments

@sherlock-admin
Copy link
Contributor

sherlock-admin commented Aug 15, 2023

ast3ros

medium

Result from Chainlink oracle price is not checked for validity

Summary

Chainlink oracle price is not checked for validity.

Vulnerability Detail

In Kept contract, the ETH price is retrieved from Chainlink oracle to calculate the keeper fee.

    (, int256 answer, , ,) = ethTokenOracleFeed().latestRoundData();

https://github.com/sherlock-audit/2023-07-perennial/blob/main/root/contracts/attribute/Kept.sol#L62

However, the price is not sufficiently validated. The updatedAt result is ignored and is not checked with a threshold to ensure the price is not too old.

Impact

The stale price will lead to incorrect keeper fee calculation.

Code Snippet

https://github.com/sherlock-audit/2023-07-perennial/blob/main/root/contracts/attribute/Kept.sol#L62

Tool used

Manual Review

Recommendation

Add a checking

        function _etherPrice() private view returns (UFixed18) {
-           (, int256 answer, , ,) = ethTokenOracleFeed().latestRoundData();
+           (uint80 roundID, int256 answer, , uint256 updatedAt, uint80 answeredInRound) = ethTokenOracleFeed().latestRoundData();
+           require(answer > 0,"Negative Price");
+           require(block.timestamp <= updatedAt + stalePriceDelay, "Stale price");
            return UFixed18Lib.from(Fixed18Lib.ratio(answer, 1e8)); 
        }

Duplicate of #159

@github-actions github-actions bot added Medium A valid Medium severity issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels Aug 18, 2023
@sherlock-admin
Copy link
Contributor Author

3 comment(s) were left on this issue during the judging contest.

141345 commented:

d

n33k commented:

unhandled stale price returned from latestRoundData()

darkart commented:

The same as 120

@sherlock-admin sherlock-admin changed the title Cheery Porcelain Barbel - Result from Chainlink oracle price is not checked for validity ast3ros - Result from Chainlink oracle price is not checked for validity Aug 23, 2023
@sherlock-admin sherlock-admin added Non-Reward This issue will not receive a payout and removed Medium A valid Medium severity issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels Aug 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Non-Reward This issue will not receive a payout
Projects
None yet
Development

No branches or pull requests

1 participant