Skip to content
Business logic Audit finding Intermediate

Redundant gas charge in native addvalidation function leads to unnecessary gas costs

The native_addValidation function charges an extra storage-read gas fee before calling a function that already charges for its own storage access, so users pay more gas than necessary when the chain is not in its Proof-of-Stake phase. An attacker does not gain anything; the issue is a small, persistent overcharge for every affected transaction.

rionnaldi Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

55711 sc insight redundant gas charge in native addvalidation function leads to unnecessary gas costs

Submitted on Oct 4th 2025 at 10:32:50 UTC by @rionnaldi for Attackathon | VeChain Hayabusa Upgrade

Description

Brief / Intro

The native_addValidation function within builtin/staker_native.go contains a redundant gas charge that causes users to pay higher transaction fees than necessary. When the Proof-of-Stake (PoS) consensus mechanism is not active, the function explicitly charges for a storage read (SloadGas) before calling a subsequent function that already accounts for its own storage access costs. This results in duplicated gas charges and wasted gas for the user.

Vulnerability Details

{% stepper %} {% step %}

What the code does

When PoS is inactive (if !isPoSActive), the function:

  • Explicitly charges thor.SloadGas to the transaction gas meter.
  • Calls Authority.Native(env.State()).Get(...) to retrieve validator information. {% endstep %}

{% step %}

Why this is redundant

The Get function itself reads from contract storage to fetch authority details. Its metered implementation charges the necessary gas for these SLOAD operations. Therefore the explicit charger.Charge(thor.SloadGas) performed prior to the Get call duplicates charging for the same storage read. {% endstep %} {% endstepper %}

Impact Details

{% hint style="info" %} Users incur a small but unnecessary extra gas cost (one SLOAD worth) whenever native_addValidation is invoked while the chain is not in its PoS phase. Although the waste per transaction is small, it is persistent and accumulates across many transactions. {% endhint %}

Proof of Concept

The issue appears in builtin/staker_native.go:

{% code title="builtin/staker_native.go" %}

Go
	isPoSActive, err := Staker.NativeMetered(env.State(), charger).IsPoSActive()
	if err != nil {
		return nil, err
	}

	if !isPoSActive {
		// This gas charge is redundant. The subsequent call to Authority.Native.Get()
		// will account for its own SLOAD operations.
		charger.Charge(thor.SloadGas) // a.getEntry(ValidatorMaster)

		exists, endorser, _, _, err := Authority.Native(env.State()).Get(thor.Address(args.Validator))
		if err != nil {
			return nil, err
		}
		if !exists {
			return nil, staker.NewReverts("authority required in transition period")
		}
		if thor.Address(args.Endorser) != endorser {
			return nil, staker.NewReverts("endorser required")
		}
	}

{% endcode %}

The Authority.Native(env.State()).Get() call performs its own SLOAD operations and charges for them. The preceding charger.Charge(thor.SloadGas) duplicates that charge when isPoSActive is false.

Recommendation

Remove the explicit charger.Charge(thor.SloadGas) in the if !isPoSActive block and rely on the metered Authority.Native.Get() call to account for storage access gas.

References

The original report as published on Immunefi, by rionnaldi. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

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 code explicitly charges for a storage read before calling a function that already meters and charges for the same storage read.

Impact

Users incur a small but unnecessary extra gas cost (one SLOAD worth) whenever native_addValidation is invoked while the chain is not in its PoS phase.

What the attacker needed

Chain not in PoS phase; calling native_addValidation

The fix

The explicit charger.Charge(thor.SloadGas) in the if !isPoSActive block should be removed and the metered Authority.Native.Get() call relied upon to account for storage access gas.

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.

When you send a transaction on a blockchain, you pay a fee called gas for the work the network does. This code charged the user twice for the same small piece of work: once directly and once inside a function it called. The result is that users paid a little more than they should, but nothing was stolen or broken.

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 rionnaldi

View all

2 more disclosed reports, best first.

More from VeChain Hayabusa Upgrade

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.