Skip to content
Audit finding Intermediate

Missing price staleness check for WEETH_AGGREGATOR

The EETHPriceAdapter contract uses two Chainlink oracles to compute the eETH price but only checks the staleness of the ETH/USD oracle, not the WETH/ETH oracle. An attacker could exploit a stale WETH/ETH price to cause an incorrect eETH price, potentially leading to inaccurate valuations.

oakcobalt Follow

Originally disclosed on Code4rena

Submitted by oakcobalt

Code reference: EETHPriceAdapter.sol#L115

EETHPriceAdapter::latestRoundata() is called by PriceOracle::getAssetPriceFromChainlink. It provides price of eETH in baseCurrency(USD) by using two chainlink oracles - ETH/USD(BASE_AGGREGATOR), WETH/ETH (WEETH_AGGREGATOR).

The problem is the flow of getAssetPriceFromChainlink -> EETHPriceAdapter::latestRoundata() would only have price staleness check for BASE_AGGREGATOR oracle, but no price staleness check for WEETH_AGGREGATOR oracle.

Missing price staleness check for one of the two oracle could result in a invalid eETH/USD price.

Proof of Concept

Flows: PriceOracle::getAssetPriceFromChainlink -> EETHPriceAdapter::latestRoundata

In EETHPriceAdapter::latestRoundData, only the data feed timestamp(updatedAT_) of BASE_AGGREGATOR is passed as return values. WETH_AGGREGATOR is invoked using a simplified method latestAnswer instead of latestRoundData and no meta data of the price feed is passed.

//src/oracles/EETHPriceAdapter.sol
    function latestRoundData()
        public
        view
        returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)
    {
    ...
            (
            uint80 roundId_,
            int256 basePrice,
            uint256 startedAt_,
            uint256 updatedAt_,
            uint80 answeredInRound_
        ) = BASE_AGGREGATOR.latestRoundData();

|>      int256 eETHBasePrice = _convertWEETHPrice(basePrice, weETHPrice);

        return (roundId_, eETHBasePrice, startedAt_, updatedAt_, answeredInRound_);
    }

EETHPriceAdapter.sol#L115

In PriceOracle::getAssetPriceFromChainlink, only BASE_AGGREGATOR’s price staleness is checked.

//src/PriceOracle.sol

    function getAssetPriceFromChainlink(address asset) public view returns (uint256) {
        AggregatorV2V3Interface sourceAgg = assetChainlinkAggregators[asset];
        require(address(sourceAgg) != address(0), Errors.ASSET_AGGREGATOR_NOT_EXIST);

        (uint80 roundId, int256 answer, , uint256 updatedAt, uint80 answeredInRound) = sourceAgg.latestRoundData();
          //@audit when calling EETHPriceAdapter::latestRoundData, only BASE_AGGREGATOR's staleness will be checked. WEETH_AGGREGATOR's staleness check is missing.
|>        require(answer > 0, Errors.ASSET_PRICE_IS_ZERO);
|>        require(updatedAt != 0, Errors.ORACLE_PRICE_IS_STALE);
|>        require(answeredInRound >= roundId, Errors.ORACLE_PRICE_IS_STALE);

        return uint256(answer);
    }

PriceOracle.sol#L181

Since two chainlink price feeds are used, both price feed’s staleness need to be checked to ensure a valid answer.

Recommended mitigation steps

Consider adding staleness check for WEETH_AGGREGATOR in EETHPriceAdapter::latestRoundata.

thorseldon (BendDAO) acknowledged

0xTheC0der (judge) commented:

Close to M-2 “Use of deprecated chainlink function: latestAnswer()” from the automated findings report, but still different due to staleness consideration. Therefore, valid.


The original report as published on Code4rena, by oakcobalt. 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 code uses the deprecated latestAnswer function for the WETH/ETH oracle, which does not provide timestamp data, so no staleness check is performed for that oracle.

What the attacker needed

None

The fix

The contract should be updated to use latestRoundData for the WETH/ETH oracle and include a staleness check for it.

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.

This report is about a smart contract that calculates the price of a token called eETH. It uses two price sources, but only checks if one of them is up-to-date. If the other source gives an old price, the calculated price could be wrong, which might cause problems for the system that relies on it.

More by oakcobalt

View all

50 more disclosed reports, best first.

More from BendDAO Invitational

View all

The newest disclosed reports for this program.

Similar reports

Same bug class and techniques, clearest first.