Skip to content
DoS Audit finding Intermediate

Freeze Bridge via Non-UTF8 Token Name/Symbol/Denom

A permissionless function allows anyone to deploy an ERC20 token with a non-UTF8 symbol, causing the orchestrator's event parser to fail and return an error. This prevents the bridge from updating its last checked block, effectively freezing all attestations and the bridge.

nascent Follow

Originally disclosed on Code4rena

Submitted by nascent

Manual insertion of non-utf8 characters in a token name will break parsing of logs and will always result in the oracle getting in a loop of failing and early returning an error. The fix is non-trivial and likely requires significant redesign.

Proof of Concept

Note the c0 in the last argument of the call data (invalid UTF8).

It can be triggered with:

data memory bytes = hex"f7955637000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000461746f6d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000046e616d6500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000673796d626fc00000000000000000000000000000000000000000000000000000";
gravity.call(data);

The log output is as follows:

    ERC20DeployedEvent("atom", "name", ❮utf8 decode failed❯: 0x73796d626fc0, 18, 2)

Which hits this code path:

    let symbol = String::from_utf8(input.data[index_start..index_end].to_vec());
    trace!("Symbol {:?}", symbol);
    if symbol.is_err() {
        return Err(GravityError::InvalidEventLogError(format!(
            "{:?} is not valid utf8, probably incorrect parsing",
            symbol
        )));
    }

And would cause an early return here:

let erc20_deploys = Erc20DeployedEvent::from_logs(&deploys)?;

Never updating last checked block and therefore, this will freeze the bridge by disallowing any attestations to take place. This is an extremely low cost way to bring down the network.

Recommendation

This is a hard one. Re-syncing is permanently borked because, on the Go side, there is seemingly no way to ever process the event nonce because protobufs do not handle non-utf8 strings. The validator would report they need event nonce N from the orchestrator, but they can never parse the event N. Seemingly, validators & orchestrators would have to know to ignore that specific event nonce. But it is a permissionless function, so it can be used to effectively permanently stop attestations & the bridge until a new Gravity.sol is deployed.

One potential fix is to check in the solidity contract if the name contains valid utf8 strings for denom, symbol and name. This likely will be expensive though. Alternatively, you could require that validators sign ERC20 creation requests and perform checks before the transaction is sent.

jkilpatr (Althea) confirmed:

This is a valid and well considered bug.

I do disagree about the difficulty of the fix though, if we fail to parse the token name as utf8 we can just encode the bytes themselves in hex and pass that along. The result will be perfectly valid if a little unergonomic.

albertchon (judge) commented:

Clever, great catch

The original report as published on Code4rena, by nascent. 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-based bridge that connects an Ethereum chain to a Cosmos chain. The bridge works through two cooperating pieces: a Solidity contract (Gravity.sol) deployed on the Ethereum side, and an orchestrator written in Rust that runs alongside each validator. The orchestrator watches Ethereum logs, parses the events emitted by the contract, and turns them into attestations that validators sign and submit on the Cosmos side.

One of the events the orchestrator must parse is ERC20DeployedEvent, emitted when a new ERC20 token is registered with the bridge. The event carries the token's denom, name, symbol and further numeric fields. The orchestrator decodes these fields from the raw log data and uses them to build the attestation. If parsing fails, the whole event-processing step fails.

Setup

The finding was submitted to the Gravity Bridge program on Code4rena by the researcher nascent. The report does not describe any special accounts, tooling or versions. The only precondition is the ability to call the bridge contract, which the report stresses is a permissionless function: anyone can register a token, so anyone can emit an ERC20DeployedEvent.

Finding it

The researcher noticed that the symbol field is decoded as a UTF-8 string, but nothing on the Ethereum side enforces that the bytes supplied are valid UTF-8. A caller can therefore insert non-UTF-8 bytes into one of these fields. When the orchestrator later tries to decode the log, the decode fails, and the failure is not isolated to that one event: it aborts the whole batch of events being processed.

Exploitation

Step 1: craft calldata with an invalid UTF-8 symbol

The researcher supplies raw call data in which the last argument (the symbol) ends in the byte c0, which is not valid UTF-8. The report notes the c0 in the last argument explicitly.

Text
data memory bytes = hex"[redacted]";
gravity.call(data);

The payload registers a token with denom atom, name name and a symbol whose bytes are 73796d626fc0 (symbo followed by c0). The call is made through gravity.call(data).

Step 2: observe the log output

The contract emits the event, and the log shows the symbol field failing to decode:

Text
    ERC20DeployedEvent("atom", "name", ❮utf8 decode failed❯: 0x73796d626fc0, 18, 2)

The event is emitted successfully on the Ethereum side. The failure happens later, in the orchestrator.

Step 3: the orchestrator hits the UTF-8 check

The decoded event reaches the parsing code in ethereum_events.rs, which converts the symbol bytes into a String and returns an error if that conversion fails:

Text
    let symbol = String::from_utf8(input.data[index_start..index_end].to_vec());
    trace!("Symbol {:?}", symbol);
    if symbol.is_err() {
        return Err(GravityError::InvalidEventLogError(format!(
            "{:?} is not valid utf8, probably incorrect parsing",
            symbol
        )));
    }

Because c0 is not valid UTF-8, symbol.is_err() is true and the function returns GravityError::InvalidEventLogError.

Step 4: the error aborts the whole event batch

The error propagates up to the event watcher, where the entire set of deploys is parsed in one call:

Text
let erc20_deploys = Erc20DeployedEvent::from_logs(&deploys)?;

The ? means the error returns early from the watcher. The watcher never reaches the point where it updates the last checked block. On the next iteration it reads the same logs again, hits the same invalid event, and fails again.

Root cause

The contract does not validate that the symbol is valid UTF-8, and the report recommends adding such checks for denom, name and symbol. The orchestrator, on the other hand, assumes those fields are UTF-8 and treats a decode failure as a fatal error for the entire batch rather than skipping the offending event. Because the last checked block is only advanced after a successful parse, the orchestrator is stuck permanently on the same log range.

The report also points at a deeper problem on the Go side: protobufs do not handle non-UTF-8 strings, so there is seemingly no way to ever process that event nonce. The validator would report that it needs event nonce N from the orchestrator, but the orchestrator can never parse event N. The report describes the fix as non-trivial and likely requiring significant redesign.

Impact

An attacker can freeze the bridge at extremely low cost. Once the invalid event is on chain, the orchestrator loops on the failing parse, never updates its last checked block, and no attestations can take place. Because the registration function is permissionless, the report states it can be used to effectively stop attestations and the bridge permanently until a new Gravity.sol is deployed. Re-syncing does not help, since the event nonce can never be processed. The report hedges the permanence with "effectively" and ties recovery to deploying a new contract.

Fix

The report offers two directions rather than a single patch. One is to check in the Solidity contract that the denom, name and symbol contain valid UTF-8 strings, which the researcher expects to be expensive. The other is to require validators to sign ERC20 creation requests and perform checks before the transaction is sent.

The maintainer (jkilpatr, Althea) confirmed the bug and disagreed about the difficulty of the fix: if the token name fails to parse as UTF-8, the bytes themselves can be encoded in hex and passed along, which produces a perfectly valid result even if it is a little unergonomic. The judge (albertchon) called it a clever catch. The report does not state which fix was ultimately implemented.

Variants to test

Hunting notes

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 lets tokens move between two different blockchains: an Ethereum chain and a Cosmos chain. Think of it as a courier service between two countries. On the Ethereum side there is a smart contract (a program that lives on the blockchain and runs automatically) called Gravity.sol. On the Cosmos side there are validators, computers run by different people that keep the Cosmos chain running, and each validator runs a helper program called an orchestrator, written in Rust.

The orchestrator's job is to watch the Ethereum chain, read the announcements the contract makes, and turn them into signed statements (attestations) that the validators submit on the Cosmos side. One of the announcements it must read is ERC20DeployedEvent, which is emitted whenever someone registers a new ERC20 token (a standard kind of token on Ethereum) with the bridge. That announcement contains the token's denom, name and symbol, plus further numeric fields.

The researcher, nascent, found that the contract does not check that the symbol is valid UTF-8 text. The orchestrator, however, insists that these fields are valid UTF-8 text. UTF-8 is the standard way computers encode characters such as letters and digits into bytes; some byte sequences are valid UTF-8 and some are not. If someone registers a token whose symbol contains bytes that are not valid UTF-8, the orchestrator cannot read the announcement. Worse, the failure is not limited to that one announcement: it stops the orchestrator from processing the whole batch of announcements, and because the orchestrator only records how far it has read after a successful batch, it gets stuck on the same announcement forever. The bridge freezes. The report calls this an extremely low cost way to bring down the network.

Setup

The finding was submitted to the Gravity Bridge program on Code4rena by the researcher nascent. The report does not describe any special accounts, tooling or versions. The only precondition is the ability to call the bridge contract, which the report stresses is a permissionless function: anyone can register a token, so anyone can cause an ERC20DeployedEvent to be emitted. "Permissionless" means there is no approval step and no allowlist; if you can send a transaction, you can use the function.

Finding it

The researcher noticed that the symbol field in the event is decoded as a UTF-8 string, but nothing on the Ethereum side enforces that the bytes supplied are valid UTF-8. A caller can therefore insert non-UTF-8 bytes into one of these fields. When the orchestrator later tries to decode the log, the decode fails, and the failure is not isolated to that one event: it aborts the whole batch of events being processed.

To understand why this matters, picture a postal sorting office. The Ethereum contract is the sender: it writes an address label in whatever handwriting it likes. The orchestrator is the sorting machine: it can only read neat printed labels, and if one label is unreadable it stops the entire conveyor belt rather than setting that one parcel aside. A single badly written label jams everything behind it.

Exploitation

Step 1: craft calldata with an invalid UTF-8 symbol

The researcher supplies raw call data in which the last argument (the symbol) ends in the byte c0, which is not valid UTF-8. The report notes the c0 in the last argument explicitly. "Calldata" is the bundle of bytes you send with a transaction to tell a smart contract what to do; it is the instruction sheet attached to the parcel.

Text
data memory bytes = hex"[redacted]";
gravity.call(data);

Line by line:

  • data memory bytes = hex"..."; declares a chunk of raw bytes, written in hexadecimal (base 16, where each pair of characters is one byte). This is the instruction sheet for the contract.
  • The long hex string is the encoded call. Inside it you can read, in ASCII (the basic character encoding where each letter is one byte), the words atom, name and symbo, each padded with zero bytes. The very last meaningful byte is c0, which is not a valid UTF-8 character on its own.
  • gravity.call(data); sends those bytes to the bridge contract, the way you would hand the instruction sheet to the clerk at the counter.

The payload registers a token with denom atom, name name and a symbol whose bytes are 73796d626fc0 (symbo followed by c0). The call is made through gravity.call(data).

Step 2: observe the log output

The contract emits the event, and the log shows the symbol field failing to decode. A "log" here is a public record the contract writes onto the blockchain; anyone can read it afterwards, and the orchestrator reads it automatically.

Text
    ERC20DeployedEvent("atom", "name", ❮utf8 decode failed❯: 0x73796d626fc0, 18, 2)

Line by line:

  • ERC20DeployedEvent is the name of the announcement.
  • "atom" is the denom, "name" is the token name, both readable text.
  • ❮utf8 decode failed❯: 0x73796d626fc0 is the symbol field: the tool that printed the log could not turn those bytes into text, so it shows them as raw hex instead. 0x is simply the conventional prefix meaning "the following is hexadecimal".
  • 18 and 2 are the remaining numeric fields of the event.

The event is emitted successfully on the Ethereum side. The failure happens later, in the orchestrator.

Step 3: the orchestrator hits the UTF-8 check

The decoded event reaches the parsing code in ethereum_events.rs, which converts the symbol bytes into a String and returns an error if that conversion fails. A String in Rust is a piece of text that is guaranteed to be valid UTF-8; the conversion is therefore a check as much as a translation.

Text
    let symbol = String::from_utf8(input.data[index_start..index_end].to_vec());
    trace!("Symbol {:?}", symbol);
    if symbol.is_err() {
        return Err(GravityError::InvalidEventLogError(format!(
            "{:?} is not valid utf8, probably incorrect parsing",
            symbol
        )));
    }

Line by line:

  • let symbol = String::from_utf8(...) takes the slice of the log data that holds the symbol (input.data[index_start..index_end], copied with .to_vec()) and tries to turn it into a valid text string. The result is not the text itself but a container that says either "here is the text" or "this failed".
  • trace!("Symbol {:?}", symbol); writes a debug line recording what was decoded, for troubleshooting.
  • if symbol.is_err() { asks whether the conversion failed.
  • return Err(GravityError::InvalidEventLogError(format!(...))) builds an error value describing the problem and immediately hands it back to the caller, stopping this function. The message includes the failed value and the words "is not valid utf8, probably incorrect parsing".

Because c0 is not valid UTF-8, symbol.is_err() is true and the function returns GravityError::InvalidEventLogError.

Step 4: the error aborts the whole event batch

The error propagates up to the event watcher, where the entire set of deploys is parsed in one call:

Text
let erc20_deploys = Erc20DeployedEvent::from_logs(&deploys)?;

Line by line:

  • Erc20DeployedEvent::from_logs(&deploys) asks the event type to read all the deploy announcements in deploys at once and produce a list of parsed events.
  • The ? at the end is Rust shorthand for "if this returned an error, stop here and pass the error up to my caller". It is the conveyor belt stopping: one bad parcel halts the whole line.

The ? means the error returns early from the watcher. The watcher never reaches the point where it updates the last checked block. A "block" is a bundle of transactions added to the blockchain; "last checked block" is the bookmark the orchestrator keeps so it knows where to resume next time. On the next iteration it reads the same logs again, hits the same invalid event, and fails again. It is like a reader who dog-ears the page, fails to read one word, and starts the same page over every morning without ever moving the bookmark.

Root cause

The contract does not validate that the symbol is valid UTF-8, and the report recommends adding such checks for denom, name and symbol. The orchestrator, on the other hand, assumes those fields are UTF-8 and treats a decode failure as a fatal error for the entire batch rather than skipping the offending event. Because the last checked block is only advanced after a successful parse, the orchestrator is stuck permanently on the same log range.

The report also points at a deeper problem on the Go side: protobufs do not handle non-UTF-8 strings, so there is seemingly no way to ever process that event nonce. A "nonce" here is a sequence number: each event has one, and validators track which numbers they have already handled. "Protobuf" is a standard data format used to send messages between programs, and it expects text fields to be valid text. The validator would report that it needs event nonce N from the orchestrator, but the orchestrator can never parse event N. The report describes the fix as non-trivial and likely requiring significant redesign.

Impact

An attacker can freeze the bridge at extremely low cost. Once the invalid event is on chain, the orchestrator loops on the failing parse, never updates its last checked block, and no attestations can take place. Because the registration function is permissionless, the report states it can be used to effectively stop attestations and the bridge permanently until a new Gravity.sol is deployed. Re-syncing does not help, since the event nonce can never be processed. The report hedges the permanence with "effectively" and ties recovery to deploying a new contract.

Fix

The report offers two directions rather than a single patch. One is to check in the Solidity contract that the denom, name and symbol contain valid UTF-8 strings, which the researcher expects to be expensive. The other is to require validators to sign ERC20 creation requests and perform checks before the transaction is sent.

The maintainer (jkilpatr, Althea) confirmed the bug and disagreed about the difficulty of the fix: if the token name fails to parse as UTF-8, the bytes themselves can be encoded in hex and passed along, which produces a perfectly valid result even if it is a little unergonomic. The judge (albertchon) called it a clever catch. The report does not state which fix was ultimately implemented.

Variants to test

Hunting notes

Glossary

  • API: a defined way for one program to ask another program to do something, like a service counter with fixed forms.
  • Attestation: a signed statement by a validator that it has seen and verified something, used to agree on what happened on another chain.
  • Block: a bundle of transactions added to a blockchain at once; the chain is a sequence of blocks.
  • Blockchain: a shared record book kept by many computers, where entries are hard to change after the fact.
  • Bridge: software that lets tokens or data move between two separate blockchains.
  • Calldata: the raw bytes sent with a transaction to tell a smart contract what to do.
  • Contract (smart contract): a program deployed on a blockchain that runs automatically when called.
  • Cosmos: a family of blockchains and the software framework used to build them.
  • Decimals: the number of decimal places a token uses to represent fractions of a unit.
  • Denom: the short identifier for a token's denomination, essentially its ticker on the Cosmos side.
  • ERC20: the standard interface for tokens on Ethereum.
  • Ethereum: a blockchain that can run smart contracts.
  • Event (log): a public record a smart contract writes onto the blockchain, which other software can read.
  • Event nonce: a sequence number attached to each event so validators can track which ones they have processed.
  • Go: a programming language; the report refers to Go-side code that handles the Cosmos messages.
  • Hexadecimal (hex): a way of writing bytes using base 16, where each pair of characters represents one byte.
  • Last checked block: the bookmark an orchestrator keeps recording how far it has read the Ethereum chain.
  • Nonce: a number used once, here a counter that orders events.
  • Orchestrator: the Rust program each validator runs to watch Ethereum and prepare attestations.
  • Permissionless: usable by anyone without approval or an allowlist.
  • Protobuf: a standard format for encoding messages between programs, which expects text fields to be valid text.
  • Rust: a programming language; the orchestrator is written in it.
  • Solidity: the programming language used to write smart contracts on Ethereum.
  • String: in Rust, a piece of text guaranteed to be valid UTF-8.
  • Symbol: the short ticker of a token, such as its abbreviated name.
  • Transaction: a signed instruction sent to a blockchain, such as a call to a contract.
  • UTF-8: the standard way to encode characters as bytes; not every byte sequence is valid.
  • Validator: a computer that participates in keeping a blockchain running and signs statements about it.
  • ? operator: Rust shorthand that stops a function and passes an error up to its caller.

More by nascent

View all

4 more disclosed reports, 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.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.