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.
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:
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:
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
- 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
- There are 3 gas reports,
[10, 10, 20] - The lowest report will be 10 and the index will be 0
- The computed
lowestGasUsedwill only be applied for the first executor, even though the 1st index is also the lowest report, these are 2 such reports - 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
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
- Have three gas reports with values [10, 10, 20].
- The lowest report is 10 and its index is 0.
- The computed lowestGasUsed is applied only to the first executor (index 0), even though index 1 also has the lowest report.
- 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.