Skip to content
Business logic Audit finding Intermediate

Challenger misses discrepancy events, allowing executors to perform malicious actions

The Challenger bot's end-of-block handler overwrote the list of discrepancy challenges with timeout challenges before sending them, so discrepancy events were never sent for processing. A malicious Executor could therefore submit invalid output proposals without being challenged.

0xAlix2 Follow

Originally disclosed on Code4rena

Submitted by 0xAlix2

https://github.com/initia-labs/opinit-bots/blob/640649b97cbfa5782925b7dc8c0b62b8fa5367f6/challenger/child/handler.go#L95

Finding Description and Impact

The Challenger is a critical process responsible for monitoring the Executor’s output proposals and challenging any invalid submissions. It ensures the integrity of the rollup’s state and prevents malicious actions by the Executor.

The Challenger operates by accumulating emitted events from both the L1 and L2 chains. At the end of every L2 block, a handler is triggered to validate the events and determine if any challenges need to be issued.

When a user deposits tokens into the L2 by sending an InitiateTokenDeposit transaction on the L1, the following event is emitted:

Event emission in L1:

sdk.UnwrapSDKContext(ctx).EventManager().EmitEvent(sdk.NewEvent(
	types.EventTypeInitiateTokenDeposit,
	sdk.NewAttribute(types.AttributeKeyBridgeId, strconv.FormatUint(bridgeId, 10)),
	sdk.NewAttribute(types.AttributeKeyL1Sequence, strconv.FormatUint(l1Sequence, 10)),
	sdk.NewAttribute(types.AttributeKeyFrom, req.Sender),
	sdk.NewAttribute(types.AttributeKeyTo, req.To),
	sdk.NewAttribute(types.AttributeKeyL1Denom, coin.Denom),
	sdk.NewAttribute(types.AttributeKeyL2Denom, l2Denom),
	sdk.NewAttribute(types.AttributeKeyAmount, coin.Amount.String()),
	sdk.NewAttribute(types.AttributeKeyData, hex.EncodeToString(req.Data)),
))

This event is caught by the host component in the Challenger and saved to the child’s database at the end of the L1 block:

Host event saving:

// save all pending events to child db
err = eventhandler.SavePendingEvents(h.stage.WithPrefixedKey(h.child.DB().PrefixedKey), h.eventQueue)

When the Executor finalizes the deposit on the L2 by sending a FinalizeTokenDeposit message, the following event is emitted:

Event emission in L2:

event := sdk.NewEvent(
	types.EventTypeFinalizeTokenDeposit,
	sdk.NewAttribute(types.AttributeKeyL1Sequence, strconv.FormatUint(req.Sequence, 10)),
	sdk.NewAttribute(types.AttributeKeySender, req.From),
	sdk.NewAttribute(types.AttributeKeyRecipient, req.To),
	sdk.NewAttribute(types.AttributeKeyDenom, coin.Denom),
	sdk.NewAttribute(types.AttributeKeyBaseDenom, req.BaseDenom),
	sdk.NewAttribute(types.AttributeKeyAmount, coin.Amount.String()),
	sdk.NewAttribute(types.AttributeKeyFinalizeHeight, strconv.FormatUint(req.Height, 10)),
)

The child component of the Challenger catches this event and saves it in the child’s database.

At the end of an L2 block, the endBlockHandler is called:

func (ch *Child) endBlockHandler(ctx types.Context, args nodetypes.EndBlockArgs) error {
	// ...

	// check value for pending events
1@>	challenges, processedEvents, err := ch.eventHandler.CheckValue(ctx, ch.eventQueue)
	if err != nil {
		return err
	}
	pendingChallenges = append(pendingChallenges, challenges...)

	// check timeout for unprocessed pending events
  	unprocessedEvents := ch.eventHandler.GetUnprocessedPendingEvents(processedEvents)
2@>	challenges, timeoutEvents := ch.eventHandler.CheckTimeout(args.Block.Header.Time, unprocessedEvents)
3@>	pendingChallenges = append(pendingChallenges, challenges...)

	// ...

	ch.eventHandler.DeletePendingEvents(processedEvents)
	ch.eventHandler.SetPendingEvents(timeoutEvents)
4@>	ch.challenger.SendPendingChallenges(challenges)
	return nil
}

The handler performs the following steps:

  • Checks for discrepancies in the mapped events, such as InitiateTokenDeposit and FinalizeTokenDeposit (1@).
  • Checks for timeout events among unprocessed pending events (2@).
  • Groups both types of events into pendingChallenges for later handling/challenging/rollbacks (3@).

However, at 4@, the handler sends only the challenges variable, which is overridden when fetching timeout events. This results in discrepancies being missed, as they are not included in pendingChallenges.

The SendPendingChallenges function sends these challenges to a channel (c.challengeCh) for asynchronous handling. The challengeHandler function, running in a separate goroutine, processes challenges from this channel, the discrepancy events won’t be included in this.

This defeats the purpose of the Challenger bot, allowing malicious Executors to act without detection.

Recommended Mitigation Steps

func (ch *Child) endBlockHandler(ctx types.Context, args nodetypes.EndBlockArgs) error {
	// ...

	ch.eventHandler.DeletePendingEvents(processedEvents)
	ch.eventHandler.SetPendingEvents(timeoutEvents)
-	ch.challenger.SendPendingChallenges(challenges)
+	ch.challenger.SendPendingChallenges(pendingChallenges)
	return nil
}

beer-1 (Initia) confirmed and commented:

Mitigation here.

challenges => pendingChallengs

https://github.com/initia-labs/opinit-bots/blame/90594098d4dc95f14bd409c69aee2fd772610041/challenger/child/handler.go#L95

berndartmueller (warden) commented:

I just want to mention that those challenges are currently not acted upon (e.g., not sent to an alerting system, or actions and counter-measures taken):

https://github.com/initia-labs/opinit-bots/blob/640649b97cbfa5782925b7dc8c0b62b8fa5367f6/challenger/handler.go#L72-L77

func (c *Challenger) handleChallenge(ctx types.Context, challenge challengertypes.Challenge) error {
	// TODO: warning log or send to alerting system
	ctx.Logger().Error("challenge", zap.Any("challenge", challenge))

	return nil
}

Therefore, the challenger is currently not effective and it does not prevent malicious actions.

a_kalout (warden) commented:

@berndartmueller - The protocol already has those challenges errored out in the logs, which are, of course, caught somewhere else on their end. If you’re referencing the TODO, it is an improvement for later. This doesn’t change the fact that the discrepancy events are being thrown away.

Our responsibility here is to make sure it is caught alongside the timeout issues, which are not being caught. This is enough impact to show that this is a high-severity issue.

LSDan (judge) commented:

I agree. Leaving this in place as high.


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 handler reused the same variable name for timeout challenges, overwriting the discrepancy challenges before they were passed to SendPendingChallenges.

Impact

Discrepancy challenges are never sent for processing, so a malicious Executor could act without detection; however, a warden noted that challenges are currently only logged and not acted upon, so the Challenger is not effective regardless.

What the attacker needed

Malicious or faulty Executor; Challenger bot running

The fix

The handler was fixed to send the combined pendingChallenges list instead of the overwritten challenges variable.

How it was found

  1. A user deposits tokens on L1, emitting an InitiateTokenDeposit event that the Challenger stores.
  2. The Executor finalises the deposit on L2, emitting a FinalizeTokenDeposit event that the Challenger also stores.
  3. At the end of an L2 block, the handler checks for discrepancies and collects them into a challenges list.
  4. The handler then checks for timeouts, overwriting the challenges variable with the timeout results.
  5. Only the overwritten challenges variable is sent to SendPendingChallenges, so the discrepancy findings are dropped.

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.

A rollup has a watchdog program called the Challenger that checks whether the operator (the Executor) is cheating. When the watchdog found a mismatch between a deposit and its finalisation, it put that finding in one list, but then replaced that list with a different list of timeout findings before sending anything onward. So the cheating was noticed but the alarm was thrown away.

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.