Skip to content
Business logic Audit finding Intermediate

Executors will get underpaid while excessive gas will be refunded to the requestor

The gas metering function caps each executor's gas payment by dividing the remaining gas by the full replication factor, even when some executors are outliers and receive no gas. This causes honest executors to be underpaid, with the leftover gas refunded to the data requester.

zxriptor Follow

Originally disclosed on Sherlock

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

The protocol has acknowledged this issue.

Found by

zxriptor

Summary

Not accounting for outliers in execution gas usage may result in honest executors being underpaid, even if the gas limit is not exhausted, with the remaining amount refunded to the data requestor.

Root Cause

In gas_meter.go:137 a maximum gas that an executor can receive (gasUsed) is capped by the remainingExecGas divided by the replicationFactor:

GOLANG
func MeterExecutorGasUniform(executors []string, gasReport uint64, outliers []bool, replicationFactor uint16, gasMeter *types.GasMeter) {
	executorGasReport := gasMeter.CorrectExecGasReportWithProxyGas(gasReport)
@>	gasUsed := min(executorGasReport, gasMeter.RemainingExecGas()/uint64(replicationFactor))
	for i, executor := range executors {
		if outliers != nil && outliers[i] {
			continue
		}
		gasMeter.ConsumeExecGasForExecutor(executor, gasUsed)
	}
}

At the same time, gas consumption is not recorded for outliers. If the reported gas (executorGasReport) exceeds gasMeter.RemainingExecGas() / uint64(replicationFactor), honest executors will be underpaid, even though gasMeter.RemainingExecGas() will not be zero after consumption is recorded.

Eventually, this unused residue will be refunded to the data requester instead of being paid to the executors.

Internal Pre-conditions

  1. Remaining exec gas is not enough to cover the expenses of ALL executors.
  2. There are outliers among executors.

External Pre-conditions

None

Attack Path

Consider the following scenario:

Remaining exec gas: 90,000 Replication factor: 10 Gas reported: 10,000 (uniform) Outliers: 2

The gasUsed will be calculated as 90,000 (remaining gas) / 10 (replication factor) = 9,000

Therefore, 8 honest executors will receive 9,000 gas each totaling to 72,000. Residue exec gas: 18,000 (will be refunded to data requestor).

Each validator is underpaid by 1,000 gas, even though there is enough remaining gas to fully compensate them and even refund 8,000 gas to the data requester.

Impact

Executors are underpaid.

Please note that a similar conceptual mistake exists in the MeterExecutorGasDivergent function.

PoC

No response

Mitigation

Reduce the replication factor by the number of outliers to achieve a fairer distribution:

GOLANG
func MeterExecutorGasUniform(executors []string, gasReport uint64, outliers []bool, replicationFactor uint16, gasMeter *types.GasMeter) {
	executorGasReport := gasMeter.CorrectExecGasReportWithProxyGas(gasReport)
---	gasUsed := min(executorGasReport, gasMeter.RemainingExecGas()/uint64(replicationFactor))
+++     gasUsed := min(executorGasReport, gasMeter.RemainingExecGas()/uint64(replicationFactor - len(outliers)))
	for i, executor := range executors {
		if outliers != nil && outliers[i] {
			continue
		}
		gasMeter.ConsumeExecGasForExecutor(executor, gasUsed)
	}
}

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

Root cause

The gas cap calculation uses the full replication factor instead of subtracting the number of outliers, so the per-executor gas is lower than it could be.

Impact

Honest executors are underpaid, and the unused gas is refunded to the data requester.

What the attacker needed

Remaining exec gas is not enough to cover all executors; There are outliers among executors

The fix

The replication factor should be reduced by the number of outliers when calculating the gas cap.

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, executors are paid gas for their work. The code calculates each executor's payment by dividing the remaining gas by the total number of executors, but it does not adjust for executors who are skipped (outliers). As a result, the honest executors get less gas than they should, and the extra gas goes back to the person who requested the work.

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 zxriptor

View all

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