Skip to content
Business logic Audit finding Intermediate

StaderOracle - Strict equal can cause no consensus if trusted nodes are removed before consensus

The oracle contract requires an exact number of submissions to reach consensus, but if the trusted node count changes, that exact number may never be met, preventing updates. This could block oracle updates for at least one period and leave stale price data that affects future submissions.

dwward3n Follow

Originally disclosed on Code4rena

Submitted by dwward3n

https://github.com/code-423n4/2023-06-stader/blob/main/contracts/StaderOracle.sol#L148 https://github.com/code-423n4/2023-06-stader/blob/main/contracts/StaderOracle.sol#L290

        if (
            submissionCount == trustedNodesCount / 2 + 1 &&
            _exchangeRate.reportingBlockNumber > exchangeRate.reportingBlockNumber
        ) {
            updateWithInLimitER(
                _exchangeRate.totalETHBalance,
                _exchangeRate.totalETHXSupply,
                _exchangeRate.reportingBlockNumber
            );
        }

In submitExchangeRateData, consensus is reached if submissionCount is strictly equal to desired number. However, trustNodesCount can be decreased and this condition can be never met.

        if ((submissionCount == (2 * trustedNodesCount) / 3 + 1)) {
            lastReportedSDPriceData = _sdPriceData;
            lastReportedSDPriceData.sdPriceInETH = getMedianValue(sdPrices);
            delete sdPrices;

In submitSDPrice, if this case happens, sdPrices doesn’t get deleted and it will affect the next submission batch’s price.

Proof of Concept

In the above snippet, let’s assume trustedNodesCount = 10, submissionCount = 5. The condition doesn’t meet for now (5 != 10/2+1). Then trustedNodesCount decreases to 9. Next time when a node submits, trustedNodesCount = 9, submissionCount = 6. Then the condition cannot be met since (6 != 9/2+1).

Recommended Mitigation Steps

Replace strict equal with equal or greater than. Or replace it with greater than and decrease the right side.

Not sure about adding cooldown for add/remove trusted nodes.

manoj9april (Stader) confirmed and commented:

Thanks, we will fix this.

Picodes (judge) commented:

Keeping medium severity because of the sponsor’s label, but the justification of why it qualifies for Med and what the impacts of the bug are is insufficient.

For most functions, it seems the submissionCount depends on the reportingBlockNumber so the impact would only be one period where the oracle couldn’t be updated, which doesn’t qualify without additional justification. For example, for submitSocializingRewardsMerkleRoot and submitMissedAttestationPenalties, the impact may be more important.

sanjay-staderlabs (Stader) commented:

This is fixed.


The original report as published on Code4rena, by dwward3n. 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 consensus check uses strict equality instead of a greater-than-or-equal comparison, so a change in the trusted node count can make the required submission count unreachable.

Impact

The oracle may fail to update for at least one period, and stale price data could affect the next submission batch.

What the attacker needed

Trusted node count changes; submission count reaches a value that skips the exact…

The fix

The strict equality check should be replaced with a greater-than-or-equal comparison, and the project confirmed it was fixed.

How it was found

  1. Assume there are 10 trusted nodes and 5 submissions have been received.
  2. The trusted node count is reduced to 9.
  3. A new submission arrives, making the submission count 6.
  4. The condition 6 == 9/2+1 is false, so consensus is never reached.

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 oracle collects votes from trusted nodes to update data like exchange rates. The code only accepts a result when the number of votes exactly equals a threshold. If the number of trusted nodes changes, the vote count might skip past that exact number, so the update never happens.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More from Stader Labs

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.