Open code423n4 opened 3 years ago
shw
The getEtherPrice function in the contract FSDNetwork fetches the ETH price from a Chainlink aggregator using the latestRoundData function. However, there are no checks on roundID nor timeStamp, resulting in stale prices.
getEtherPrice
FSDNetwork
latestRoundData
roundID
timeStamp
Referenced code: FSDNetwork.sol#L376-L381
Add checks on the return data with proper revert messages if the price is stale or the round is uncomplete, for example:
(uint80 roundID, int256 price, , uint256 timeStamp, uint80 answeredInRound) = ETH_CHAINLINK.latestRoundData(); require(answeredInRound >= roundID, "..."); require(timeStamp != 0, "...");
Fixed in PR#7.
Labeling this as medium risk as stale ether price could put funds at risk.
Handle
shw
Vulnerability details
Impact
The
getEtherPrice
function in the contractFSDNetwork
fetches the ETH price from a Chainlink aggregator using thelatestRoundData
function. However, there are no checks onroundID
nortimeStamp
, resulting in stale prices.Proof of Concept
Referenced code: FSDNetwork.sol#L376-L381
Recommended Mitigation Steps
Add checks on the return data with proper revert messages if the price is stale or the round is uncomplete, for example: