The Standard

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

Calls to the Chainlink Oracle in `LiquidationPool::distributeAssets()` function lack checks for stale prices

Summary

In the LiquidationPool::distributeAssets() function, there are two calls to the Chainlink price feeds using latestRoundData() function. Both of these lack a check for stale price.

Vulnerability Details

Lack of stale price cheks in the following function.

function distributeAssets(
ILiquidationPoolManager.Asset[] memory _assets,
uint256 _collateralRate,
uint256 _hundredPC
) external payable {
consolidatePendingStakes();
@> (, int256 priceEurUsd, , , ) = Chainlink.AggregatorV3Interface(eurUsd).latestRoundData();
uint256 stakeTotal = getStakeTotal();
uint256 burnEuros;
uint256 nativePurchased;
for (uint256 j = 0; j < holders.length; j++) {
Position memory _position = positions[holders[j]];
uint256 _positionStake = stake(_position);
if (_positionStake > 0) {
for (uint256 i = 0; i < _assets.length; i++) {
ILiquidationPoolManager.Asset memory asset = _assets[i];
if (asset.amount > 0) {
@> (, int256 assetPriceUsd, , , ) = Chainlink.AggregatorV3Interface(asset.token.clAddr.latestRoundData();
.
.
.

Impact

As the price feeds might become stale due to variety of reasons it might cause incorrect distribution of assets, negatively impacting the reliability of the protocol for the stakers.

Moreover, PriceCaulculator contract would be impacted. Even though it's out of scope it needs to be emphasized that lack of sufficient validation after latestRoundData calls might cause arbitrary collateral manipulation by users exploiting the resulting price slippage.

Tools Used

Manual review

Recommendations

Verification that the parameter updatedAt read from the latestRoundData() calls is not older than a set amount of time timeBuffer.

if (updatedAt < block.timestamp - timeBuffer) {
revert(StalePriceFeed());
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.