Skip to content
This repository was archived by the owner on Jan 7, 2024. It is now read-only.
This repository was archived by the owner on Jan 7, 2024. It is now read-only.

0xbepresent - Chainlink.latestRoundData() may return stale results #18

@sherlock-admin

Description

@sherlock-admin

0xbepresent

medium

Chainlink.latestRoundData() may return stale results

Summary

The Oracle.getUnderlyingPrice() function is used to get the price of tokens, the problem is that the function does not check for stale results.

Vulnerability Detail

The Oracle.getUnderlyingPrice() function is used in InsuranceFund, MarginAccount and AMM contracts. The Oracle.getUnderlyingPrice() helps to determine the tokens prices managed in the contracts.

The problem is that there is not check for stale data. There are some reasons that the price feed can become stale.

Impact

Since the token prices are used in many contracts, stale data could be catastrophic for the project.

Code Snippet

The Oracle.getUnderlyingPrice() is used by the next contracts:

Tool used

Manual review

Recommendation

Read the updatedAt return value from the Chainlink.latestRoundData() function and verify that is not older than than specific time tolerance.

require(block.timestamp - udpatedData < toleranceTime, "stale price");

Metadata

Metadata

Assignees

No one assigned

    Labels

    Has DuplicatesA valid issue with 1+ other issues describing the same vulnerabilityMediumA valid Medium severity issueRewardA payout will be made for this issueSponsor ConfirmedThe sponsor acknowledged this issue is validWill FixThe sponsor confirmed this issue will be fixed

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions