Skip to content
DoS Audit finding Advanced

Funding settlement will be DOS'd for a time after the phaseID change of an underlying chainlink aggregator

The oracle incorrectly assumes that Chainlink round IDs increment by one, but they actually pack a phase ID and aggregator round ID. When the phase ID increments, the round ID jumps by 2^64, causing calls to settle funding to revert for up to 24 hours, which delays funding settlement and results in different TWAP values being used, leading to yield loss for some users.

0x52 Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-04-hubble-exchange-judging/issues/177

Found by

0x52

Summary

Oracle incorrectly assumes that roundID is always incremented by one but this is not the case. Chainlink's roundID is actually two values packed together: phaseId and aggregatorRoundId. When the phaseID is incremented the roundID increases by 2 ** 64. After a phaseID increment all calls to settle funding will revert until an entire funding interval has elapsed. Since all markets are settled simultaneously, even a single oracle incrementing will result in all market funding being DOS'd. Although this funding can be made up later it will user different TWAP values which will result in users being paid differently causing loss of yield to a portion of all users.

Vulnerability Detail

https://snowtrace.io/address/0x976b3d034e162d8bd72d6b9c989d545b839003b0#code#L206

  function getAnswer(uint256 _roundId)
    public
    view
    virtual
    override
    returns (int256 answer)
  {
    if (_roundId > MAX_ID) return 0;

    (uint16 phaseId, uint64 aggregatorRoundId) = parseIds(_roundId);
    AggregatorV2V3Interface aggregator = phaseAggregators[phaseId];
    if (address(aggregator) == address(0)) return 0;

    return aggregator.getAnswer(aggregatorRoundId);
  }

The above code is from the ETH/USD aggregator on AVAX, It can be seen that the roundId is made up of 2 packed components, the phaseId and aggregatorRoundId. As explained in the summary, when the phaseId is incremented 2 ** 64 "rounds" will be skipped. When currentRound - 1 is inevitably queried after this increment, the call will revert because that round doesn't exist this DOS will last for up to 24 hours depending on market settings. After the DOS ends, settingFunding will be able to catch up but it will now calculate the funding rate with different TWAP values.

Impact

Loss of yield to a portion of all users in every market each time there is a phaseId shift

Code Snippet

Tool used

Manual Review

Recommendation

I would recommend using a try block when calling the aggregator. If the roundID is nonzero and is reverting then the oracle needs try again with a lower phaseId

Discussion

asquare08

This is a valid issue. We will fix it with post-mainnet releases because we are using trusted oracle (deployed on hubbleNet) with mainnet release and any updates to that will be notified prior.

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

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

Impact

Funding settlement is delayed for up to 24 hours after a phase ID change, and when it resumes, different TWAP values are used, causing some users to lose yield.

What the attacker needed

Chainlink aggregator phase ID changes

The fix

The recommendation is to use a try block when calling the aggregator and, if the round ID is nonzero and reverting, retry with a lower phase ID.

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 oracle (a service that provides external data) to get price information. The oracle's round numbers are not simple sequential numbers; they include a phase identifier. When the phase changes, the round number jumps by a huge amount, and the contract's assumption that the previous round is always one less breaks, causing funding settlement to fail temporarily.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by 0x52

View all

211 more disclosed reports, best first.

More from Hubble Exchange

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.