Skip to content
Business logic Audit finding Intermediate

Apply oracle update doesn’t check for duplicate validator votes

The oracle update validation sums voting power from all submitted votes without checking for duplicate validators, so a single validator can submit multiple votes to reach the required two-thirds threshold and change oracle prices alone.

0xAlix2 Follow

Originally disclosed on Code4rena

Submitted by 0xAlix2

When an Oracle update is required, validators cast votes for the change. An UpdateOracle message is then sent from one of the bridge executors. This message invokes the ApplyOracleUpdate function, which calls UpdateOracle. In this function, the incoming votes are validated, and if deemed valid, the Oracle prices are updated.

The main vote validation occurs in the ValidateVoteExtensions function, which performs three critical steps:

  1. Calculates the total voting power of all validators in the current validator set.
  2. Sums the voting power of the validators who voted on the change.
  3. Verifies that the voting power of the validators who voted meets or exceeds the threshold of (2/3 + 1) of the total voting power.

https://github.com/initia-labs/OPinit/blob/7da22a78f367cb25960ed9c536500c2754bd5d06/x/opchild/l2connect/utils.go#L20-L124

func ValidateVoteExtensions(
	ctx sdk.Context,
	valStore ValidatorStore,
	height int64,
	chainID string,
	extCommit cometabci.ExtendedCommitInfo,
) error {
	// ...

	var (
		// Total voting power of all validators in current validator store.
		totalVP int64
		// Total voting power of all validators that submitted valid vote extensions.
		sumVP int64
	)

	totalBondedTokens, err := valStore.TotalBondedTokens(ctx)
	if err != nil {
		return err
	}
	totalVP = totalBondedTokens.Int64()

	for _, vote := range extCommit.Votes {
		valConsAddr := sdk.ConsAddress(vote.Validator.Address)
		power, err := valStore.GetPowerByConsAddr(ctx, valConsAddr)
		if err != nil {
			// return fmt.Errorf("failed to get validator %X power: %w", valConsAddr, err)

			// use only current validator set, so ignore if the validator of the vote is not in the set.
			continue
		}

		// snip... (unrelated code)

		sumVP += power.Int64()
	}

	// This check is probably unnecessary, but better safe than sorry.
	if totalVP <= 0 {
		return fmt.Errorf("total voting power must be positive, got: %d", totalVP)
	}

	// If the sum of the voting power has not reached (2/3 + 1) we need to error.
	if requiredVP := ((totalVP * 2) / 3) + 1; sumVP < requiredVP {
		return fmt.Errorf(
			"insufficient cumulative voting power received to verify vote extensions; got: %d, expected: >=%d",
			sumVP, requiredVP,
		)
	}

	return nil
}

As shown above, it just loops over the votes and adds the voting power of each entry, without validating if that validator is a duplicate entry.

This allows a malicious validator to solely change the oracle prices without the need of other validators’ votes.

Recommended mitigation steps

Refactor ValidateVoteExtensions to throw an error if a duplicate validator is encountered.

	func ValidateVoteExtensions(
		ctx sdk.Context,
		valStore ValidatorStore,
		height int64,
		chainID string,
		extCommit cometabci.ExtendedCommitInfo,
	) error {
		// ...

		totalBondedTokens, err := valStore.TotalBondedTokens(ctx)
		if err != nil {
			return err
		}
		totalVP = totalBondedTokens.Int64()

+		seenValidators := make(map[string]bool)

		for _, vote := range extCommit.Votes {
+			if seenValidators[vote.Validator.String()] {
+				return fmt.Errorf("duplicate vote for validator %s", vote.Validator.String())
+			}
+			seenValidators[vote.Validator.String()] = true

			// ...
		}

		// ...
	}

beer-1 (Initia) confirmed and commented:

Thanks for your report, I will add this fix.

a_kalout (warden) commented:

I could see this as a high-severity issue. One malicious validator could change the Oracle prices, and unlike malicious propers/executors, there’s no way to “catch” this. The way I’m looking at this is anyone can become a validator, and the above report allows any validator to solely update the Oracle prices; which clearly breaks the “quorum” logic for updating price here. This leaves us with likelihood arguably medium/high and a clear high impact.

LSDan (judge) commented:

I would agree if there was a follow-through impact reported that showed the Oracle price causing a direct loss of funds. The reporting warden did not take it to that level, so as reported, the impact is that the Oracle price is wrong, full stop. The follow on impacts are handwavy hypotheticals, making this a medium.


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

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 validation loop does not track which validators have already voted, allowing the same validator's voting power to be counted multiple times.

Impact

A single malicious validator could unilaterally update oracle prices, breaking the quorum requirement; the judge noted the report did not demonstrate direct loss of funds, so it was rated medium.

What the attacker needed

Be a validator

The fix

The validation should reject duplicate validator entries, as the project confirmed it will add this fix.

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 many blockchain systems, changing important data like prices requires agreement from a large portion of validators. This code counts each vote's power but forgets to ensure each validator only votes once, so one validator can pretend to be many and meet the threshold alone.

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 0xAlix2

View all

39 more disclosed reports, best first.

More from Initia Rollup Modules

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.