Detectors related to improper usage of Oracle APIs
Describe the desired feature
Hello folks,
I am working on a bachelor's thesis related to smart contract security. My goal is to use static analysis to detect improper usage of Oracle APIs and, therefore, prevent possible vulnerabilities. I have created a few detectors in Slither, currently focusing on Chainlink data validation. I plan to support other Oracles and generalise the detectors, if possible.
The code is available here (it's a clone, not a fork of Slither at the moment): repository. To see what gets detected, you can check the tests. For example when calling priceFeed.latestRoundData(), the return value price should be checked:
(
uint80 roundID,
int256 price,
,
uint256 updatedAt,
uint80 answeredInRound
) = priceFeedDAIETH.latestRoundData();
require(price_check(price));
require(updatedAt - block.timestamp < 500);
require(answeredInRound > roundID);
Omitting such a check can lead to potentially serious issues if the oracles provide incorrect data. The detector checks whether the price-check is present.
Would you be interested in such a type of detector in Slither? It does not detect Solidity/Vyper syntax-related bugs but could be a valuable detector anyway. Maybe running such a detector could be hidden behind a feature flag.
I am looking forward to hearing any feedback from you on both the code and the idea of such detectors. Also, I am more than happy to improve/refactor the code to fit Slither better.
Cheers, Talfao
Source: crytic/slither