Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

Olivierdem - Oracle feed not validated enough #36

Closed
sherlock-admin opened this issue Oct 18, 2022 · 0 comments
Closed

Olivierdem - Oracle feed not validated enough #36

sherlock-admin opened this issue Oct 18, 2022 · 0 comments
Labels

Comments

@sherlock-admin
Copy link
Contributor

sherlock-admin commented Oct 18, 2022

Olivierdem

medium

Oracle feed not validated enough

Summary

Oracle data feed is insufficiently validated. There is no check for stale price and round completeness.

Vulnerability Detail

Price can be stale and can lead to wrong spot64x64 return value.

Impact

Impact could be big since the stale price would happen in the getDeltaStrikePrice64x64 function.

Code Snippet

https://github.com/sherlock-audit/2022-09-knox/blob/main/knox-contracts/contracts/pricer/PricerInternal.sol?plain=1#L49-L54

function _latestAnswer64x64() internal view returns (int128) {
       (, int256 basePrice, , , ) = BaseSpotOracle.latestRoundData();
       (, int256 underlyingPrice, , , ) =
           UnderlyingSpotOracle.latestRoundData();

       return ABDKMath64x64.divi(underlyingPrice, basePrice);
   }

Tool used

Manual Review

Recommendation

The oracle gives back 5 values when called, so don't ignore 4 of them.
Validate Data Feed with some require:

function _latestAnswer64x64() internal view returns (int128) {
        (uint80 roundID, int256 basePrice, , uint256 timestamp, uint80 answeredInRound) = 
      BaseSpotOracle.latestRoundData();
         require(basePrice > 0, "ChainLink: basePrice price <= 0");
         require(answeredInRound >= roundID, "ChainLink: Stale price");
         require(timestamp > 0, "ChainLink: Round not complete");

        (roundID, int256 underlyingPrice, , timestamp, answeredInRound ) =
            UnderlyingSpotOracle.latestRoundData();
         require(underlyingPrice > 0, "ChainLink: underlyingPrice price <= 0");
         require(answeredInRound >= roundID, "ChainLink: Stale price");
         require(timestamp > 0, "ChainLink: Round not complete");

        return ABDKMath64x64.divi(underlyingPrice, basePrice);
    }

Duplicate of #137

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant