code-423n4 / 2024-05-bakerfi-findings

4 stars 4 forks source link

Missing checks for whether the L2 Sequencer is active #14

Closed c4-bot-10 closed 3 months ago

c4-bot-10 commented 4 months ago

Lines of code

https://github.com/code-423n4/2024-05-bakerfi/blob/main/contracts/oracles/EthOracle.sol#L31

Vulnerability details

Description

Chainlink recommends that users using price oracles, check whether the Arbitrum Sequencer is active. If the sequencer goes down, the Chainlink oracles will have stale prices from before the downtime, until a new L2 OCR transaction goes through. Users who submit their transactions via the L1 Delayed Inbox will be able to take advantage of these stale prices. Use the Chainlink oracle recommended checks to determine whether the sequencer is offline or not, and don't allow operations to take place while the sequencer is offline.

Link to code:

    function getLatestPrice() public view override returns (IOracle.Price memory price) {
@-->    (, int256 answer, uint256 startedAt, uint256 updatedAt,) = _ethPriceFeed.latestRoundData();
        if ( answer<= 0 ) revert InvalidPriceFromOracle();        
        if ( startedAt ==0 || updatedAt == 0 ) revert InvalidPriceUpdatedAt();    

        price.price = uint256(answer);
        price.lastUpdate = updatedAt;
    }

Tools Used

Manual review

Recommended Mitigation Steps

Use the Chainlink oracle recommended checks to determine whether the sequencer is offline or not, and don't allow operations to take place while the sequencer is offline.

Assessed type

Other

stalinMacias commented 4 months ago

I'd like to add the next information with regards to the usage of Chainlink Oracles on this protocol.

At first sight, because the contracts in scope, one could think that the protocol plans to use Chainlink Oracles as the Oracles to pull data from, but, digging in the settings of the Strategies, it becomes clear that the Oracles the protocol will use are not Chainlink Oracles. Why? Because the strategies are going to work with COLLATERAL/USD oracles.

This information is enough to deduct that the Chainlink Oracles won't be used by the protocol, but instead, the protocol will use the Pyth Oracles. Pyth Oracles are quoted on ASSET/USD. We can query the available Pyth feeds here, and get all the Pyth Oracle addresses across all the Chains here.

Price Feed IDs ===> https://pyth.network/developers/price-feed-ids 0x6df640f3b8963d8f8358f791f352b8364513f6ab1cca5ed3f1f7b5448980e784 <===> WSTETH/USD 0x15ecddd26d49e1a8f1de9376ebebc03916ede873447c1255d2d5891b92ce5717 <===> CBETH/USD 0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace <===> ETH/USD



All in all, I think all issues related to Chainlink Oracles should belong to the QA category because they offer information to the protocol **in case they plan to update the Oracle's configuration to use Chainlink Oracles**, but, **at the moment of the audit, all the Oracle's setting is configured to work with Pyth Oracles**, thus, ***any issues related to Chainlink oracles are not a problem for this protocol.***
c4-judge commented 3 months ago

0xleastwood marked the issue as primary issue

hvasconcelos commented 3 months ago

We have protection to protect against stale prices

0xleastwood commented 3 months ago

All instances of the price oracle are in _getPosition() which uses governance defined settings for price queries and these rely on getSafeLatestPrice() which reverts when the price is stale.

c4-judge commented 3 months ago

0xleastwood marked the issue as unsatisfactory: Invalid

t0x1cC0de commented 3 months ago

Hey @0xleastwood, I would like to point out that:

0xleastwood commented 3 months ago

No reason for users to call getLatestPrice() and this does not impact the core protocol. Keeping it as is.