code-423n4 / 2022-01-yield-findings

1 stars 0 forks source link

Oracle prices could be not fresh #41

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

0x1f8b

Vulnerability details

Impact

Unsafe oracle call.

Proof of Concept

The contract Cvx3CrvOracle doesn't check that the data is fress, it call the method latestRoundData, this method allow you to run some extra validations, but these validations were not made.

According to the chain.link documentation:

You can check answeredInRound against the current roundId. If answeredInRound is less than roundId, the answer is being carried over. If answeredInRound is equal to roundId, then the answer is fresh.

So it's required to check something like this:

        (roundId, daiPrice, , updateTime, answeredInRound ) = DAI.latestRoundData();
        require(daiPrice > 0, "Chainlink price <= 0");
        require(updateTime != 0, "Incomplete round");
        require(answeredInRound >= roundId, "Stale price");

Reference:

Tools Used

Manual review.

Recommended Mitigation Steps

Apply the mentioned changes.

devtooligan commented 2 years ago

dup of #2

GalloDaSballo commented 2 years ago

Duplicate of #136