Skip to content
Business logic Audit finding Intermediate

Cannot actually submit evidence

The message handler for submitting bad signature evidence was not registered, so validators could not report collusion. This removed a disincentive for validators to collude and take over the bridge.

jmak Follow

Originally disclosed on Code4rena

Submitted by jmak

Impact

The SubmitBadSignatureEvidence is not actually registered in the handler and hence no one can actually submit this message, rendering the message useless. This harms the security model of Gravity since validators have no disincentive to attempt to collude and take over the bridge.

Proof of Concept

The SubmitBadSignatureEvidence handler is omitted from module/x/gravity/handler.go

Tools Used

Visual inspection

Recommended Mitigation Steps

Handle the MsgSubmitBadSignatureEvidence in module/x/gravity/handler.go

jkilpatr (Althea) confirmed and patched:

This was resolved here

https://github.com/althea-net/cosmos-gravity-bridge/commit/ad6bd78d4c968c3eef5a8ab7a38b42cd3269d186

This is a valid bug considering this fix is not included in the code hash up for review.

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

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 4 min read.

Context

Gravity Bridge is a Cosmos SDK module that connects a Cosmos chain to an Ethereum chain. Validators observe events on the Ethereum side and sign attestations about them, and the Cosmos side acts on those signatures. Because the security of the bridge rests on validators behaving honestly, the module includes a message, MsgSubmitBadSignatureEvidence, that lets anyone report evidence that a validator signed something it should not have. The message is meant to create a disincentive against collusion: if validators can be shown to have signed conflicting or invalid attestations, that evidence can be submitted on chain.

This report is about that message not being reachable at all.

Setup

The review was a code review of the Gravity Bridge repository, carried out by visual inspection rather than by running a chain or sending transactions. No accounts, roles, deployed versions or tooling beyond reading the source are described. The relevant file is the module's message handler:

Text
module/x/gravity/handler.go

Finding it

The researcher looked at how the module routes incoming messages and noticed that the handler for SubmitBadSignatureEvidence is missing from the handler file. In a Cosmos SDK module, every message type that the chain should accept has to be registered in the module's handler so that the router can dispatch it. If a message type is not registered there, a transaction carrying it cannot be processed by the module, so the message can never be submitted.

The consequence is that MsgSubmitBadSignatureEvidence exists as a type but is unreachable in practice. The researcher describes the message as useless as a result.

Exploitation

There is no request, payload or command in the report: the finding is established by reading the handler registration, not by sending a transaction. The steps are therefore the reasoning rather than an attack sequence.

Step 1: Identify the message that underpins the incentive model

The security model of Gravity assumes validators have something to lose if they collude to take over the bridge. MsgSubmitBadSignatureEvidence is the mechanism that is supposed to provide that disincentive, by allowing bad signature evidence to be brought on chain.

Step 2: Check that the message is routed

Inspect module/x/gravity/handler.go and confirm which message types are handled. The SubmitBadSignatureEvidence handler is omitted from that file.

Step 3: Conclude the message cannot be submitted

Because the handler is not registered, no one can actually submit the message. The type is present but the path to act on it is not, so the message is rendered useless.

Root cause

The mistake is an omission in message routing: the module's handler does not register a case for MsgSubmitBadSignatureEvidence, so the router has no route for it. The report does not describe any other defence that would have caught this, and the omission is only visible by inspecting the handler registration. The confirming developer notes that the fix was not included in the code hash that was up for review, which is consistent with the handler being the place where the gap existed.

Impact

With the message unreachable, validators have no disincentive to attempt to collude and take over the bridge. The harm is to the security model of Gravity rather than to a single user: the mechanism that is supposed to deter misbehaviour cannot be invoked by anyone, honest or otherwise. The report does not describe a direct theft or fund-loss scenario beyond this weakening of the model.

Fix

The recommended mitigation is to handle MsgSubmitBadSignatureEvidence in the module handler:

Text
module/x/gravity/handler.go

The developer confirmed the issue and stated that it was resolved in a commit to the bridge repository. The developer stated that it was resolved in a commit to the bridge repository and that the bug is valid because the fix was not included in the code hash up for review.

Variants to test

These are things to check on similar Cosmos SDK modules and bridges, each with the signal that would confirm a problem.

  1. Enumerate every message type the module defines and compare it against the cases registered in the module handler. A message type with no handler case is a candidate for the same bug.
  2. Check the message service and router registration as well as the legacy handler, since a message can be defined and still not be reachable through the path the chain actually uses. A positive result is a message that no route dispatches.
  3. Look specifically at punitive or evidence-submission messages, such as slashing, fraud proof and bad signature evidence types. These are the ones whose absence quietly removes an incentive, so a missing route there has outsized impact.
  4. Confirm the reviewed code hash matches the deployed or intended code, since the confirming developer explicitly tied validity to the fix not being in the reviewed hash. A mismatch between what was reviewed and what is claimed to be fixed is worth flagging.

Hunting notes

This class of bug hides in the glue between message definitions and message routing: the handler file, the message service registration and the router. During recon, list the module's message types and trace each one to a handler; anything defined but unrouted stands out. The signal is structural rather than behavioural, which is why visual inspection of the handler was enough here. The impact argument in the report was framed around the protocol's security model, namely that validators lose their disincentive to collude, and the developer confirmed the issue as valid.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 10 min read.

What happened, in plain words

Gravity Bridge is a piece of software that connects two separate blockchains: a Cosmos chain and an Ethereum chain. Think of it as a bridge between two islands. People on one island can send things to the other island, and the bridge carries them across.

A blockchain is a shared record book that many computers keep copies of, and they all agree on what is written in it. Nobody can quietly change an old page. A bridge between two blockchains needs someone to watch one side and tell the other side what happened. In Gravity Bridge, that job belongs to validators: computers run by people who watch the Ethereum side and sign statements saying "this event really happened on Ethereum". The Cosmos side then trusts those signed statements and acts on them.

Because the whole system depends on validators telling the truth, the software includes a safety valve. It defines a special message called MsgSubmitBadSignatureEvidence. The idea is simple: if anyone can prove that a validator signed something it should not have signed, that proof can be sent to the chain. Knowing that this can happen gives validators a reason not to cheat. If they collude to take over the bridge, they risk being caught and reported.

This report is about that safety valve not working at all. The message exists in the code, but the chain has no way to accept it. So nobody can ever submit it, and the deterrent disappears.

Context

Gravity Bridge is built as a Cosmos SDK module. The Cosmos SDK is a toolkit for building blockchains, and a module is one self-contained part of a blockchain's behaviour, like one department in a large company. This particular module handles the bridge.

Here is how the bridge is meant to work, step by step:

  1. Validators watch the Ethereum chain for events, such as someone sending funds to the bridge.
  2. Each validator signs an attestation, which is a signed statement saying "I saw this event".
  3. Those signatures are collected and sent to the Cosmos chain.
  4. The Cosmos chain checks the signatures and, if enough validators agree, acts on the event.

Because the security of the bridge rests on validators behaving honestly, the module includes MsgSubmitBadSignatureEvidence. A message, in this context, is a structured request that someone sends to the blockchain, a bit like a filled-in form. This particular form lets anyone report evidence that a validator signed something it should not have. The message is meant to create a disincentive against collusion: if validators can be shown to have signed conflicting or invalid attestations, that evidence can be submitted on chain.

This report is about that message not being reachable at all.

Setup

The review was a code review of the Gravity Bridge repository. A repository is a shared folder of source code, usually hosted on a service such as GitHub, where the history of every change is kept. A code review means reading that source code carefully to look for mistakes, rather than running the software and poking at it.

The researcher used visual inspection, which simply means reading the code with your eyes. No chain was started, no transactions were sent, and no accounts, roles or deployed versions are described. The only tool was the ability to open files and read them.

The relevant file is the module's message handler:

Text
module/x/gravity/handler.go

This is a file path. The slashes separate folders, the way folders are nested on a computer. module is the top folder, x is a folder inside it (a common Cosmos SDK convention for modules), gravity is the folder for this particular module, and handler.go is the file itself. The .go ending tells you it is written in the Go programming language.

A handler is the part of the code that decides what to do with each kind of incoming message. Think of a post room in a large office: letters arrive, and the post room reads the address and sends each one to the right department. If a department is not listed in the post room's directory, letters for it simply never arrive.

Finding it

The researcher looked at how the module routes incoming messages and noticed that the handler for SubmitBadSignatureEvidence is missing from the handler file.

In a Cosmos SDK module, every message type that the chain should accept has to be registered in the module's handler. Registering means adding an entry that says "when a message of this type arrives, run this code". The router, the part that dispatches messages, can only send a message to code that has been registered. If a message type is not registered there, a transaction carrying it cannot be processed by the module, so the message can never be submitted.

A transaction is a request to change something on the blockchain, and it can carry one or more messages. If the module has no route for a message, the transaction that carries it cannot be handled by that module.

The consequence is that MsgSubmitBadSignatureEvidence exists as a type but is unreachable in practice. A type, in programming, is a definition of what a piece of data looks like: which fields it has and what they mean. Defining a form and printing it is not the same as giving the post room instructions for where to deliver it. The researcher describes the message as useless as a result.

Exploitation

There is no request, payload or command in the report. A payload is the actual content sent in a request, and a command is something typed into a terminal to make a computer do something. The finding is established by reading the handler registration, not by sending a transaction. The steps below are therefore the reasoning rather than an attack sequence. Nothing was exploited; the gap was spotted by reading.

Step 1: Identify the message that underpins the incentive model

The security model of Gravity assumes validators have something to lose if they collude to take over the bridge. Colluding means secretly working together towards a dishonest goal. MsgSubmitBadSignatureEvidence is the mechanism that is supposed to provide that disincentive, by allowing bad signature evidence to be brought on chain. A disincentive is a reason not to do something, usually because doing it carries a risk of punishment.

Step 2: Check that the message is routed

Inspect module/x/gravity/handler.go and confirm which message types are handled. The SubmitBadSignatureEvidence handler is omitted from that file. In other words, the post room's directory has no entry for this kind of letter.

Step 3: Conclude the message cannot be submitted

Because the handler is not registered, no one can actually submit the message. The type is present but the path to act on it is not, so the message is rendered useless. This is the whole finding: a definition with no route to it.

Root cause

The mistake is an omission in message routing. The module's handler does not register a case for MsgSubmitBadSignatureEvidence, so the router has no route for it. A case, in programming, is one branch of a decision: "if the message is of this type, do this". With no case for this message, the decision has no branch that matches it.

The report does not describe any other defence that would have caught this, and the omission is only visible by inspecting the handler registration. The confirming developer notes that the fix was not included in the code hash that was up for review. A code hash is a short fingerprint computed from the contents of the code, used to identify exactly which version was examined. If the fix is not in the reviewed hash, then the reviewed code is the version that still has the gap, which is consistent with the handler being the place where the gap existed.

Impact

With the message unreachable, validators have no disincentive to attempt to collude and take over the bridge. The harm is to the security model of Gravity rather than to a single user: the mechanism that is supposed to deter misbehaviour cannot be invoked by anyone, honest or otherwise.

Put another way, a fire alarm that nobody can reach still looks like a fire alarm on the wall, but it protects no one. The report does not describe a direct theft or fund-loss scenario beyond this weakening of the model.

Fix

The recommended mitigation is to handle MsgSubmitBadSignatureEvidence in the module handler:

Text
module/x/gravity/handler.go

In plain terms, add the missing entry to the post room's directory so that letters of this kind are delivered to the right department. The developer confirmed the issue and stated that it was resolved in a commit to the bridge repository. The developer stated that it was resolved in a commit to the bridge repository and that the bug is valid because the fix was not included in the code hash up for review. A commit is a saved change in a repository, with a record of what changed and when.

Variants to test

These are things to check on similar Cosmos SDK modules and bridges, each with the signal that would confirm a problem.

  1. Enumerate every message type the module defines and compare it against the cases registered in the module handler. A message type with no handler case is a candidate for the same bug.
  2. Check the message service and router registration as well as the legacy handler, since a message can be defined and still not be reachable through the path the chain actually uses. A positive result is a message that no route dispatches.
  3. Look specifically at punitive or evidence-submission messages, such as slashing, fraud proof and bad signature evidence types. These are the ones whose absence quietly removes an incentive, so a missing route there has outsized impact. Slashing means taking away a validator's staked funds as a punishment, and a fraud proof is evidence that someone cheated.
  4. Confirm the reviewed code hash matches the deployed or intended code, since the confirming developer explicitly tied validity to the fix not being in the reviewed hash. A mismatch between what was reviewed and what is claimed to be fixed is worth flagging.

Hunting notes

This class of bug hides in the glue between message definitions and message routing: the handler file, the message service registration and the router. During recon, which is the early stage of looking around a codebase to understand its shape, list the module's message types and trace each one to a handler. Anything defined but unrouted stands out.

The signal is structural rather than behavioural, which is why visual inspection of the handler was enough here. Structural means it is about how the code is put together, not about what happens when you run it. The impact argument in the report was framed around the protocol's security model, namely that validators lose their disincentive to collude, and the developer confirmed the issue as valid.

Glossary

  • Blockchain: a shared record book kept by many computers that all agree on its contents and its history.
  • Bridge: software that connects two blockchains so value or information can move between them.
  • Cosmos SDK: a toolkit for building blockchains, made of reusable parts called modules.
  • Module: one self-contained part of a blockchain's behaviour, like one department in a company.
  • Validator: a computer run by someone who helps secure a blockchain, here by watching Ethereum and signing statements about what it saw.
  • Attestation: a signed statement from a validator saying that a particular event happened.
  • Message: a structured request sent to a blockchain, like a filled-in form.
  • Handler: the code that decides what to do with each kind of incoming message, like a post room that sorts letters.
  • Register: to add an entry so that the system knows a message type exists and where to send it.
  • Router: the part of the system that dispatches each message to the code registered for it.
  • Transaction: a request to change something on the blockchain, which can carry one or more messages.
  • Type: a definition of what a piece of data looks like, including its fields and their meaning.
  • Payload: the actual content sent inside a request.
  • Command: something typed into a terminal to make a computer perform an action.
  • Code review: reading source code carefully to look for mistakes, without necessarily running it.
  • Repository: a shared folder of source code that keeps the history of every change.
  • Visual inspection: examining code by reading it with your eyes.
  • Code hash: a short fingerprint computed from the contents of code, used to identify exactly which version was examined.
  • Commit: a saved change in a repository, with a record of what changed and when.
  • Collusion: secretly working together towards a dishonest goal.
  • Disincentive: a reason not to do something, usually because doing it carries a risk of punishment.
  • Slashing: taking away a validator's staked funds as a punishment.
  • Fraud proof: evidence that someone cheated.
  • Recon: the early stage of exploring a codebase to understand its shape before looking for bugs.
  • Structural signal: a clue that comes from how the code is put together, rather than from running it.

More by jmak

View all

1 more disclosed report, best first.

More from Gravitybridge

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.