The Standard

The Standard
DeFiHardhat
20,000 USDC
View results
Submission Details
Severity: medium
Invalid

Risks of Utilizing Unvalidated 'latestRoundData' Integer Price Return in Arithmetic Operations

Summary

The project uses the latestRoundData, but there is no check to verify if the return value indicates stale data or if the returned data is greater than 0. This value is then directly used in arithmetic operations, such as division.

Vulnerability Details

https://github.com/Cyfrin/2023-12-the-standard/blob/main/contracts/LiquidationPool.sol#L218

https://github.com/Cyfrin/2023-12-the-standard/blob/main/contracts/LiquidationPool.sol#L207

The lines above utilize Chainlink's latestRoundData without verifying whether the value is greater than zero or stale. Subsequently, this value is employed in the division operation in the line below.

https://github.com/Cyfrin/2023-12-the-standard/blob/main/contracts/LiquidationPool.sol#L220

Impact

The latestRoundData function from Chainlink offers the most recent price from an oracle feed. If improperly utilized, it can introduce severe vulnerabilities in Solidity contracts. Specifically, direct utilization of this returned price in uint arithmetic poses a high risk. If the oracle feed returns a price of zero and it's used as a divisor, it will result in a 'division by zero' error, leading to transaction failure.

Tools Used

Manual

Recommendations

Similar checks like below can be incorporated.

Chainlink documentation:

https://docs.chain.link/data-feeds/price-feeds/historical-data

(uint80 roundID, int256 answer, uint256 timestamp, uint256 updatedAt, ) = registry.latestRoundData(
......
);
//Example Solution
require(updatedAt >= roundID, "Stale price");
require(timestamp != 0,"Round has not been completed.");
require(answer > 0,"Chainlink answer is reporting 0");

Similar issue:

https://github.com/sherlock-audit/2023-02-blueberry-judging/issues/94

Updates

Lead Judging Commences

hrishibhat Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Chainlink-price

hrishibhat Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Known issue
Assigned finding tags:

Chainlink-price

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.