Skip to content
DoS Audit finding Advanced

Tallying a Data Request with a wildcard expression in its consensus filter will store non-deterministic data and cause a chain halt

g Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-12-seda-protocol-judging/issues/245

Found by

g

Summary

In Tally module's EndBlock(), all tallying Data Requests will be processed. Each Data Request can have a Consensus Filter, which will be applied to every reveal object in the Data Request.

When the filter type is FilterStdDev or FilterMode, the consensus filter will be applied. The filter is treated as a path expression for querying data from a JSON object. One of the supported path expressions is the wildcard expression, which gets all the elements in the JSON object, but the results have a non-deterministic order. Due to this non-deterministic order, validators will get different dataList, freq, and maxFreq. This leads to a state divergence that will cause consensus failures, and ultimately, a chain halt.

Root Cause

In filters_util.go:36-51, any path expression is accepted and it expects that the results will have a deterministic ordering. Only the 0th-index of elems is accessed.

GOLANG
    obj, err := parser.Parse(revealBytes)
    if err != nil {
      errors[i] = true
      continue
    }
    expr, err := jp.ParseString(dataPath)
    if err != nil {
      errors[i] = true
      continue
    }
    // @audit the path exression is applied here to query elements from the reveal JSON object
    elems := expr.GetNodes(obj)
    if len(elems) < 1 {
      errors[i] = true
      continue
    }
    // @audit only the first element is returned as data
    data := elems[0].String()

Below is an example of a wildcard expression used to query a JSON object.

PSEUDOCODE
JSON: {"a": 1, "b": 2, "c": 3}
Expression: "$.*"
Results could be: [1,2,3] or [2,1,3] or [3,1,2] etc.

The results of applying the filter will be in the form of outliers and consensus, which are a []bool and bool.

GOLANG
outliers, consensus := filter.ApplyFilter(reveals, res.Errors)

outliers and consensus can be different values for different validators. These values affect the output data results, which will be stored.

GOLANG
    _, tallyResults[i] = k.FilterAndTally(ctx, req, params, gasMeter)
    // @audit the Result, ExitCode, and Consensus can be different across validators because of the non-deterministic
    // results of applying the filter
    dataResults[i].Result = tallyResults[i].Result
    dataResults[i].ExitCode = tallyResults[i].ExitCode
    dataResults[i].Consensus = tallyResults[i].Consensus
    // ... snip ...
  }

  processedReqs[req.ID] = k.DistributionsFromGasMeter(ctx, req.ID, req.Height, gasMeter, params.BurnRatio)

  dataResults[i].GasUsed = gasMeter.TotalGasUsed()
  dataResults[i].Id, err = dataResults[i].TryHash()
  // ... snip ...

// Store the data results for batching.
for i := range dataResults {
  // @audit the data results are stored, but since the data will be different across validators, there will be
  // state divergence.
  err := k.batchingKeeper.SetDataResultForBatching(ctx, dataResults[i])

Internal Pre-conditions

None

External Pre-conditions

None

Attack Path

A malicious user can abuse this.

  1. A malicious user can post multiple valid Data Requests with a wildcard expression $.* as consensus filter.
  2. Once the valid Data Requests are in "Tallying Status", the Tally module will process them and store their corresponding

Data Results for batching. Every validator here will store different values for their data results. 3. There will be a Chain Halt because there will be no consensus on the state root across validators.

Impact

Chain halt due to state divergence across validators.

PoC

None

Mitigation

Consider always sorting the result of expr.GetNodes(obj) before getting the first element as the result.

Discussion

sherlock-admin2

The protocol team fixed this issue in the following PRs/commits: https://github.com/sedaprotocol/seda-chain/pull/525

The original report as published on Sherlock, by g. 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.

What is known

A high-severity doS bug in SEDA Protocol. Sherlock made it public on 20 March 2025. Found in the 729 audit contest (finding H-11).

About DoS

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

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

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 g

View all

23 more disclosed reports, best first.

More from SEDA Protocol

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.