Skip to content
Business logic Audit finding Advanced

During addValidation if PoS not active, Authority.Native(env.State()).Get() should consume double the gas

A code change on the release branch removed a gas charge before a call to Authority.Native(..).Get() in the staker native contract, so that code path consumes less gas than intended. An attacker could exploit this to pay less gas than the protocol expects when adding a validator while proof-of-stake is inactive.

emarai Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

56362 bc insight during addvalidation if pos not active authority native env state get should consume double the gas

Submitted on Oct 15th 2025 at 03:26:07 UTC by @emarai for Attackathon | VeChain Hayabusa Upgrade

Description

Brief / Intro

A commit on the release/hayabusa branch removed the gas charge charger.Charge(thor.SloadGas) before calling Authority.Native(..).Get():

Diff
			if !isPoSActive {
-				charger.Charge(thor.SloadGas) // a.getEntry(ValidatorMaster)
+

				exists, endorser, _, _, err := Authority.Native(env.State()).Get(thor.Address(args.Validator))

However, gas still needs to be charged since Authority.Native(..).Get() is not charging it internally. A similar call in authority_native.go explicitly charges twice the amount of gas:

Go
		{"native_isEndorsed", func(env *xenv.Environment) []any {
			var nodeMaster common.Address
			env.ParseArgs(&nodeMaster)

			env.UseGas(thor.SloadGas * 2)
			listed, endorsor, _, _, err := Authority.Native(env.State()).Get(thor.Address(nodeMaster))

Relevant PR: https://github.com/vechain/thor/commit/f08442278f1eb45bae74f1fe922955c8e2f1d367

Impact Details

The gas that was supposed to be charged (200 or 400 if following authority_native.go) is not charged in the code path shown, resulting in lower gas consumption than intended.

References

{% stepper %} {% step %}

Reproduce (modify code)

Remove or comment out the call to Authority.Native(env.State()).Get in builtin/staker_native.go to demonstrate that skipping the call does not change gas consumption:

Diff
--- a/builtin/staker_native.go
+++ b/builtin/staker_native.go
@@ -186,7 +186,10 @@ func init() {
                        }

                        if !isPoSActive {
-                               exists, endorser, _, _, err := Authority.Native(env.State()).Get(thor.Address(args.Validator))
+                               // exists, endorser, _, _, err := Authority.Native(env.State()).Get(thor.Address(args.Validator))
+                               // note: skipping the call to show that no gas is charged
+                               exists := true
+                               endorser := thor.Address(args.Endorser)
                                if err != nil {
                                        return nil, err
                                }

{% endstep %}

{% step %}

Run test

Execute the specific test to observe gas usage remains unchanged:

Bash
go test -timeout 30s -run ^TestStakerNativeGasCosts$ github.com/vechain/thor/v2/builtin

Expected outcome: No difference in gas consumption when the Get call is removed, indicating the Authority.Native(env.State()).Get did not consume gas in that code path. {% endstep %} {% endstepper %}

{% hint style="info" %} The fix should ensure that a gas charge is applied where appropriate (e.g., reintroduce the charger.Charge(thor.SloadGas) before calling Authority.Native(...).Get() or make the Get call charge gas internally) to match the behavior in authority_native.go. {% endhint %}

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

Likely a removed gas charge before a state read that does not charge gas internally.

Impact

The gas that should have been charged is not charged, resulting in lower gas consumption than intended.

What the attacker needed

Proof-of-stake not active; ability to submit a validator add transaction

The fix

The fix should reintroduce the gas charge before the call or make the Get call charge gas internally.

How it was found

  1. Comment out the call to Authority.Native(env.State()).Get in builtin/staker_native.go.
  2. Run the TestStakerNativeGasCosts test.
  3. Observe that gas consumption is unchanged, showing the call did not charge 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.

Blockchain transactions cost 'gas', a fee that pays for the work done by the network. This report says a recent code change accidentally stopped charging gas for one step, so users could do that step more cheaply than intended. The author shows this by removing the step and seeing that the gas cost does not change.

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 emarai

View all

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