Skip to content
Business logic Audit finding Intermediate

Wrong amount of gas will be used in a certain case

The gas metering logic incorrectly applies the lowest gas report only to the first executor when multiple executors have the same lowest gas report, leading to incorrect gas consumption for the others.

000000 Follow

Originally disclosed on Sherlock

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

Found by

000000

Summary

Wrong amount of gas will be used in a certain case

Root Cause

When executing the tally program during the end blocker, we call gas_meter::MeterExecutorGasDivergent() when the gas reports are not uniform. There, we have the following code:

Go
	for i, gasReport := range gasReports {
		executorGasReport := gasMeter.CorrectExecGasReportWithProxyGas(gasReport)
		adjGasReports[i] = min(executorGasReport, gasMeter.RemainingExecGas()/uint64(replicationFactor))
		if i == 0 || adjGasReports[i] < lowestReport {
			lowestReporterIndex = i
			lowestReport = adjGasReports[i]
		}
	}

We get the lowest report index and its respective gas report. Then, we have a special case upon going over the executors:

Go
		if i == lowestReporterIndex {
			gasUsed = lowestGasUsed
		}
		gasMeter.ConsumeExecGasForExecutor(executor, gasUsed)

We compute a special lowestGasUsed and use it for the gas consumption. However, this fails to account for the case where 2 of the gas reports are the same, in that case we will only use the lowest gas for the first one in the array, while the second (and every next one if any) will use the normal gas.

Internal Pre-conditions

  1. The gas reports are not all the same but there are 2 or more which are the same

External Pre-conditions

No external pre-conditions

Attack Path

  1. There are 3 gas reports, [10, 10, 20]
  2. The lowest report will be 10 and the index will be 0
  3. The computed lowestGasUsed will only be applied for the first executor, even though the 1st index is also the lowest report, these are 2 such reports
  4. Incorrect gas will be consumed

Impact

Incorrect gas consumption.

PoC

No response

Mitigation

Have an array of indices with the lowest gas report value and use the lowest gas value for each of them.

Discussion

sherlock-admin2

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

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

Incorrect gas consumption occurs, which could lead to unfair gas charging for some executors.

What the attacker needed

Gas reports are not all the same; at least two gas reports are equal

The fix

The issue was fixed by the protocol team in a pull request.

How it was found

  1. Have three gas reports with values [10, 10, 20].
  2. The lowest report is 10 and its index is 0.
  3. The computed lowestGasUsed is applied only to the first executor (index 0), even though index 1 also has the lowest report.
  4. Incorrect gas is consumed for the second executor.

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.

In a blockchain system, gas is a unit that measures computational effort. When multiple executors report different gas usage, the system picks the lowest report to charge. This report shows that if two executors report the same lowest value, only the first one gets charged the lower amount, while the second is charged more, which is unfair and incorrect.

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 by 000000

View all

32 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.

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.