Skip to content
Business logic Audit finding Advanced

L2 hooks don’t execute ValidateBasic on provided messages

The L2 hook execution path skips the ValidateBasic check that is normally applied to transactions submitted via RPC. An attacker could submit a message through a bridge hook that would fail ValidateBasic, potentially causing inconsistent operation or application panics.

RadiantLabs Follow

Originally disclosed on Code4rena

Submitted by RadiantLabs

The L1 deposit function allows a depositor to send a signed payload to be executed atomically with the deposited tokens, via bridge hooks.

Within this signed payload, Cosmos Messages are executed one by one via the following steps:

  • Transaction decoder
  • Ante handler
  • Message handler for each of the messages
File: deposit.go
54: 	for _, msg := range tx.GetMsgs() {
55: 		handler := k.router.Handler(msg)
56: 		if handler == nil {
57: 			reason = fmt.Sprintf("Unrecognized Msg type: %s", sdk.MsgTypeURL(msg))
58: 			return
59: 		}
60:
61: 		_, err = handler(cacheCtx, msg)
62: 		if err != nil {
63: 			reason = fmt.Sprintf("Failed to execute Msg: %s", err)
64: 			return
65: 		}
66: 	}

In this msg loop, we miss a step that is commonly executed by BaseApp on transactions submitted via RPC:

File: baseapp.go
825: func (app *BaseApp) runTx(mode execMode, txBytes []byte) (gInfo sdk.GasInfo, result *sdk.Result, anteEvents []abci.Event, err error) {
---
873: 	tx, err := app.txDecoder(txBytes)
874: 	if err != nil {
875: 		return sdk.GasInfo{}, nil, nil, err
876: 	}
877:
878: 	msgs := tx.GetMsgs()
879: 	if err := validateBasicTxMsgs(msgs); err != nil {
880: 		return sdk.GasInfo{}, nil, nil, err
881: 	}
---
890: 	if app.anteHandler != nil {
---
934: 	}
---
954: 	// Attempt to execute all messages and only update state if all messages pass
955: 	// and we're in DeliverTx. Note, runMsgs will never return a reference to a
956: 	// Result if any single message fails or does not have a registered Handler.
957: 	msgsV2, err := tx.GetMsgsV2()
958: 	if err == nil {
959: 		result, err = app.runMsgs(runMsgCtx, msgs, msgsV2, mode)
960: 	}
---
998: }

This validateBasicTxMsgs calls ValidateBasic on all messages that implement it:

func validateBasicTxMsgs(msgs []sdk.Msg) error {
	if len(msgs) == 0 {
		return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "must contain at least one message")
	}

	for _, msg := range msgs {
		m, ok := msg.(sdk.HasValidateBasic)
		if !ok {
			continue
		}

		if err := m.ValidateBasic(); err != nil {
			return err
		}
	}

	return nil
}

This logic is missing from L2 hooks, meaning that messages that do have a ValidateBasic method will have this called bypassed as opposed to the situation of the same message submitted through RPC call.

This call can be reasonably executed by the ante handler. However, if we take as example minimove, this isn’t the case, because NewValidateBasicDecorator is included for the RPC ante handler (L90) and not the hook’s (L111-115):

File: ante.go
040: func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
---
085: 	anteDecorators := []sdk.AnteDecorator{
086: 		accnumante.NewAccountNumberDecorator(options.AccountKeeper),
087: 		ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
088: 		ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker),
089: 		moveante.NewGasPricesDecorator(),
090: 		ante.NewValidateBasicDecorator(),
091: 		ante.NewTxTimeoutHeightDecorator(),
092: 		ante.NewValidateMemoDecorator(options.AccountKeeper),
093: 		ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
094: 		ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, freeLaneFeeChecker),
095: 		// SetPubKeyDecorator must be called before all signature verification decorators
096: 		ante.NewSetPubKeyDecorator(options.AccountKeeper),
097: 		ante.NewValidateSigCountDecorator(options.AccountKeeper),
098: 		ante.NewSigGasConsumeDecorator(options.AccountKeeper, sigGasConsumer),
099: 		sigverify.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
100: 		ante.NewIncrementSequenceDecorator(options.AccountKeeper),
101: 		ibcante.NewRedundantRelayDecorator(options.IBCkeeper),
102: 		auctionante.NewAuctionDecorator(options.AuctionKeeper, options.TxEncoder, options.MevLane),
103: 		opchildante.NewRedundantBridgeDecorator(options.OPChildKeeper),
104: 	}
105:
106: 	return sdk.ChainAnteDecorators(anteDecorators...), nil
107: }
108:
109: func CreateAnteHandlerForOPinit(ak ante.AccountKeeper, signModeHandler *txsigning.HandlerMap) sdk.AnteHandler {
110: 	return sdk.ChainAnteDecorators(
111: 		ante.NewSetPubKeyDecorator(ak),
112: 		ante.NewValidateSigCountDecorator(ak),
113: 		ante.NewSigGasConsumeDecorator(ak, ante.DefaultSigVerificationGasConsumer),
114: 		ante.NewSigVerificationDecorator(ak, signModeHandler),
115: 		ante.NewIncrementSequenceDecorator(ak),
116: 	)
117: }

The consequence is that, when called through L2 hook transactions, MsgServer instances can execute messages that would not pass ValidateBasic. Depending on the specific message handling, this can lead to inconsistent operation or application panics.

Recommended Mitigation Steps

We recommend either:

  • Implementing a similar validateBasicTxMsgs() function on the hook execution logic.
  • Adding ante.NewValidateBasicDecorator() in the L2 app’s hook ante handler

Links to affected code

  • deposit.go#L46

beer-1 (Initia) confirmed and commented via Move audit, Issue F-7:

Mitigation here.


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

Impact

Messages that would fail ValidateBasic can be executed via L2 hooks, which could lead to inconsistent operation or application panics.

What the attacker needed

Ability to submit a bridge hook payload

The fix

The issue was fixed by adding the missing validation to the hook execution path, as confirmed by the project.

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, the software usually runs a basic sanity check on each message before executing it. This report found that one specific path (bridge hooks) skipped that check, so malformed messages could reach the code that actually processes them. That could cause the application to behave inconsistently or crash.

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 RadiantLabs

View all

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