Skip to content
Smart contracts Audit finding Beginner

Use of deprecated Chainlink API

The contract uses Chainlink's deprecated latestAnswer() function, which could stop working if Chainlink removes support. This would prevent the protocol from obtaining prices, causing it to halt and requiring redeployment.

0xRajeev Follow

Originally disclosed on Code4rena

Submitted by 0xRajeev, also found by cmichel and leastwood.

Impact

The contract uses Chainlink’s deprecated API latestAnswer(). Such functions might suddenly stop working if Chainlink stopped supporting deprecated APIs.

Impact: Deprecated API stops working. Prices cannot be obtained. Protocol stops and contracts have to be redeployed.

See similar Low-severity finding L11 from OpenZeppelin’s Audit of Opyn Gamma Protocol: https://blog.openzeppelin.com/opyn-gamma-protocol-audit/

This was a Medium-severity finding even in the previous version of WildCredit contest as well: https://github.com/code-423n4/2021-07-wildcredit-findings/issues/75 where it was reported that ”latestAnswer method will return the last value, but you won’t be able to check if the data is fresh. On the other hand, calling the method latestRoundData allows you to run some extra validations.”

Proof of Concept

https://github.com/code-423n4/2021-09-wildcredit/blob/c48235289a25b2134bb16530185483e8c85507f8/contracts/UniswapV3Oracle.sol#L101

See https://docs.chain.link/docs/deprecated-aggregatorinterface-api-reference/#latestanswer.

Tools Used

Manual Analysis

Recommended Mitigation Steps

Use V3 interface functions: https://docs.chain.link/docs/price-feeds-api-reference/

talegift (Wild Credit) acknowledged::

We’ll remove dependence on Chainlink completely.

The original report as published on Code4rena, by 0xRajeev. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the contract uses a deprecated Chainlink API function (latestAnswer) instead of the current recommended function (latestRoundData), which could be removed without notice.

Impact

If Chainlink stops supporting the deprecated API, the protocol cannot obtain prices and must be redeployed.

What the attacker needed

Chainlink discontinues the deprecated API

The fix

The contract should be updated to use the current Chainlink interface functions, such as latestRoundData, instead of the deprecated latestAnswer.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A smart contract relies on an outside service (Chainlink) to get price data. It uses an old, deprecated function that the service might turn off. If that happens, the contract can't get prices and stops working.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by 0xRajeev

View all

61 more disclosed reports, best first.

More from Wild Credit contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.