Crash Eth Oracle On Any LogicCallEvent
The event parser for LogicCallExecutedEvent is left unimplemented, so it panics whenever a LogicCall event is encountered. An attacker who could emit such an event would crash the oracle loop and freeze attestations.
Submitted by nascent
Likelihood: high
In eth_oracle_main_loop, get_last_checked_block is called. Followed by:
let logic_call_executed_events = web3
.check_for_events(
end_search.clone(),
Some(current_block.clone()),
vec![gravity_contract_address],
vec![LOGIC_CALL_EVENT_SIG],
)
.await;
and may hit the code path:
for event in logic_call_executed_events {
match LogicCallExecutedEvent::from_log(&event) {
Ok(call) => {
trace!(
"{} LogicCall event nonce {} last event nonce",
call.event_nonce,
last_event_nonce
);
if upcast(call.event_nonce) == last_event_nonce && event.block_number.is_some()
{
return event.block_number.unwrap();
}
}
Err(e) => error!("Got ERC20Deployed event that we can't parse {}", e),
}
}
But will panic at from_log here:
impl LogicCallExecutedEvent {
pub fn from_log(_input: &Log) -> Result<LogicCallExecutedEvent, GravityError> {
unimplemented!()
}
// snip...
}
It can/will also be triggered here in check_for_events:
let logic_calls = LogicCallExecutedEvent::from_logs(&logic_calls)?;
Attestations will be frozen until patched.
Recommendation
Implement the method.
Valid issue, but with zero probability. Since there is nothing on the module side that currently triggers arbitrary logic.
Despite the fact that it can’t currently happen this is still a good report.
Context
Gravity Bridge is a Cosmos-to-Ethereum bridge module. Part of its job is to watch the Ethereum chain for events emitted by the Gravity contract and to attest to them, so that the Cosmos side can act on what happened on Ethereum. The component in scope here is the Ethereum oracle, and specifically its main loop, eth_oracle_main_loop, which periodically determines the last block it has already processed and then searches for new events from that point onwards.
One of the event types the oracle is expected to understand is the logic call event, identified by LOGIC_CALL_EVENT_SIG. The oracle uses these events to advance its notion of the last checked block, so a failure to parse them affects the oracle's ability to make progress.
Setup
The report does not describe any accounts, roles, tooling or versions. It is a code review finding against the module source, and the only precondition it relies on is that the oracle reaches the code path that parses logic call events.
Finding it
The researcher traced eth_oracle_main_loop and noted that it calls get_last_checked_block. That function queries the chain for events:
let logic_call_executed_events = web3
.check_for_events(
end_search.clone(),
Some(current_block.clone()),
vec![gravity_contract_address],
vec![LOGIC_CALL_EVENT_SIG],
)
.await;
and may then hit this code path:
for event in logic_call_executed_events {
match LogicCallExecutedEvent::from_log(&event) {
Ok(call) => {
trace!(
"{} LogicCall event nonce {} last event nonce",
call.event_nonce,
last_event_nonce
);
if upcast(call.event_nonce) == last_event_nonce && event.block_number.is_some()
{
return event.block_number.unwrap();
}
}
Err(e) => error!("Got ERC20Deployed event that we can't parse {}", e),
}
}
The loop looks defensive: it matches on the Result returned by from_log and logs an error in the Err arm. What drew the researcher's attention was the implementation behind that call. LogicCallExecutedEvent::from_log is not implemented at all:
impl LogicCallExecutedEvent {
pub fn from_log(_input: &Log) -> Result<LogicCallExecutedEvent, GravityError> {
unimplemented!()
}
// snip...
}
Because the body is unimplemented!(), the function panics rather than returning an Err. The match in the caller therefore never gets a chance to handle the failure: the panic unwinds before the Err arm can run. The error handling in the loop gives a false sense of safety.
The researcher also noted that the same unimplemented function can be reached from check_for_events, at this line:
let logic_calls = LogicCallExecutedEvent::from_logs(&logic_calls)?;
So there is more than one route into the panicking code.
Exploitation
The report does not lay out an exploitation sequence with requests or commands. The reasoning is about reachability of the code path: whenever the oracle processes a logic call event, from_log is invoked, and the process panics. The researcher's stated consequence is that attestations will be frozen until the code is patched, because the oracle cannot continue its work once it has crashed.
The report rates likelihood as high. The maintainer's response qualifies that: the issue is valid, but with zero probability at the time, because nothing on the module side currently triggers arbitrary logic. In other words, the code path exists and would crash the oracle, but the condition that produces logic call events was not being exercised.
Root cause
The root cause is a stub implementation. LogicCallExecutedEvent::from_log is declared to return Result<LogicCallExecutedEvent, GravityError>, which invites callers to treat failure as a recoverable value, but its body is unimplemented!(), which panics. The caller in get_last_checked_block wraps the call in a match with an Err arm, which only handles a returned error, not a panic. The same applies to the ? at the from_logs call site in check_for_events: ? propagates a returned error, but cannot catch a panic. The existing error handling therefore does not defend against this failure mode.
Impact
If a logic call event is processed, the oracle panics and attestations stop until the code is patched. The maintainer confirmed the issue as valid while stating that it could not currently happen, since nothing on the module side triggers arbitrary logic. The practical impact is therefore conditional on logic call events actually being produced.
Fix
The recommendation in the report is to implement the method. The maintainer confirmed the issue as valid and described it as a good report despite the current impossibility of triggering it. The report does not describe a patch being applied.
Variants to test
- Search bridge and oracle modules for other
unimplemented!(),todo!()orpanic!()bodies behind functions that returnResult. A positive result is a call site that matches on theResultor uses?, giving the appearance of error handling that a panic would bypass. - Look for event parsers that are registered by signature but whose decoding is incomplete. A positive result is an event signature included in a filter whose corresponding parser cannot actually run.
- Check every route into a stubbed function, not just the obvious one. Here the same function is reachable both from the per-event loop and from
from_logsinsidecheck_for_events. A positive result is more than one call site that can reach the panic. - Trace what happens to a long-running process when one of its parsing steps panics. A positive result is a loop or service that stops making progress entirely rather than skipping the bad item.
Hunting notes
This kind of bug hides in code that is scaffolded but not finished: event types declared, signatures registered and call sites wired up, while the decoder itself is a stub. During review, the signal is a function that returns Result but whose body is unimplemented!(), todo!() or an unconditional panic, especially when callers visibly handle errors. The second signal is a filter that subscribes to an event signature the code cannot yet parse. The researcher showed impact by tracing the path from the oracle's main loop through get_last_checked_block and check_for_events to the panicking function, and by stating the operational consequence: attestations frozen until patched. The maintainer accepted the report as valid while noting the trigger was not currently reachable.
What happened, in plain words
Gravity Bridge is a piece of software that connects two separate blockchains: Cosmos and Ethereum. Think of it as a translator sitting between two offices that speak different languages. One of its jobs is to watch the Ethereum side for announcements (called "events") made by a contract, and then report those announcements back to the Cosmos side so that Cosmos can react to what happened on Ethereum.
The part of the software that does this watching is called the "Ethereum oracle". An oracle, in this context, is simply a program that reads information from one place and passes it on. The oracle runs a loop, meaning it repeats the same set of steps over and over: work out which block it last looked at, then search for anything new since that point.
A "block" is a bundle of transactions recorded on a blockchain, and blocks are numbered in order, so "the last block I checked" is a bookmark that tells the oracle where to resume. If the oracle cannot move that bookmark forward, it stops making progress.
One of the kinds of announcement the oracle is supposed to understand is called a "logic call event". The code that is meant to read (parse) such an event and turn it into something the program can use was never actually written. Instead, the function contains a placeholder that deliberately crashes the program when it is reached. The surrounding code looks as though it handles failures gracefully, but it does not, because a crash is not the same thing as a returned error.
The researcher who found this traced the path from the oracle's main loop down to the unfinished function and showed that, if a logic call event were ever processed, the oracle would crash and stop reporting anything until the code was fixed. The maintainer agreed the report was valid, but pointed out that at the time nothing on the module side was producing such events, so the crash could not actually be triggered yet.
Background concepts, from zero
Before walking through the code, here are the ideas you need. Each one is explained as if you had never met it.
- Blockchain: a shared record book that many computers keep copies of. Entries are grouped into blocks, and each block is chained to the previous one, which is why it is called a chain.
- Ethereum and Cosmos: two different blockchain networks. They do not natively understand each other's records, so a bridge is needed to carry information between them.
- Bridge: software that relays information or value from one blockchain to another. It has to watch one side and act on the other.
- Smart contract: a program that lives on a blockchain and runs automatically. The Gravity contract on Ethereum is one of these; it emits announcements when things happen.
- Event: a message that a smart contract publishes to say "something happened". Other software can subscribe to events instead of constantly re-reading the whole chain. It is like a shop putting a notice in the window rather than you walking in to ask every day.
- Event signature: a short identifier that says which kind of event you are interested in. The oracle uses one called
LOGIC_CALL_EVENT_SIGto filter for logic call events specifically. - Oracle: a program that reads data from one system and reports it to another. Here it reads Ethereum events and reports them to Cosmos.
- Attestation: a formal statement by the bridge that "this event really happened on Ethereum". The Cosmos side relies on attestations before it acts. If attestations stop, the bridge stops functioning.
- Main loop: the repeating cycle a long-running program follows. Each pass, it does its work and then starts again.
- Function: a named block of code that does one job and can be called from elsewhere.
- Parse: to read raw data and turn it into a structured form the program can work with. Parsing an event means decoding the announcement into fields such as a nonce.
- Nonce: a counter used once, here to number events so they can be put in order and checked for duplicates.
- Result: a common way for a function to say either "here is your answer" (success) or "here is what went wrong" (failure). The caller is expected to check which one it got.
- Panic: an unrecoverable crash inside a program. Unlike a returned error, a panic cannot be caught by ordinary error-handling code; the program unwinds and stops.
unimplemented!(): a placeholder in the Rust programming language that means "this function has not been written yet". If it is ever executed, the program panics.?operator: a shorthand in Rust that says "if the function I just called returned an error, pass that error up to my caller". It handles returned errors, not panics.match: a Rust construct that picks one of several branches depending on the value it is given. Here it distinguishes success from failure.- Code review: reading source code carefully to find problems, without necessarily running it.
Context
Gravity Bridge is a Cosmos-to-Ethereum bridge module. Part of its job is to watch the Ethereum chain for events emitted by the Gravity contract and to attest to them, so that the Cosmos side can act on what happened on Ethereum. The component in scope here is the Ethereum oracle, and specifically its main loop, eth_oracle_main_loop, which periodically determines the last block it has already processed and then searches for new events from that point onwards.
One of the event types the oracle is expected to understand is the logic call event, identified by LOGIC_CALL_EVENT_SIG. The oracle uses these events to advance its notion of the last checked block, so a failure to parse them affects the oracle's ability to make progress.
In plain terms: the oracle keeps a bookmark of the last block it has dealt with. Each round, it looks for new announcements after that bookmark. If it cannot read one of those announcements, it cannot move the bookmark, and the whole reporting process stalls.
Setup
The report does not describe any accounts, roles, tooling or versions. It is a code review finding against the module source, and the only precondition it relies on is that the oracle reaches the code path that parses logic call events.
In other words, you do not need to install anything or log in anywhere to understand this finding. It is about reading the code and following the path it would take at runtime.
Finding it
The researcher traced eth_oracle_main_loop and noted that it calls get_last_checked_block. That function queries the chain for events:
let logic_call_executed_events = web3
.check_for_events(
end_search.clone(),
Some(current_block.clone()),
vec![gravity_contract_address],
vec![LOGIC_CALL_EVENT_SIG],
)
.await;
Line by line, in plain words:
let logic_call_executed_events = web3starts a new variable that will hold the events found, and begins a call on an object calledweb3, which is the program's connection to the Ethereum network..check_for_events(calls a helper that searches the chain for events.end_search.clone(),passes the starting point of the search. The.clone()makes a copy so the original value is not consumed.Some(current_block.clone()),passes the ending point of the search, wrapped inSome, which means "there is a value here". Together, these two arguments define the range of blocks to look at.vec![gravity_contract_address],passes a list containing the address of the Gravity contract, so only events from that contract are considered.vec![LOGIC_CALL_EVENT_SIG],passes a list containing the event signature, so only logic call events are considered.)closes the call,.awaitwaits for the network search to finish, and the result is stored in the variable.
Why this step matters: this is where the oracle asks the network "did anything relevant happen between these two blocks?". The answer is a list of events, and the next piece of code is supposed to read each one.
and may then hit this code path:
for event in logic_call_executed_events {
match LogicCallExecutedEvent::from_log(&event) {
Ok(call) => {
trace!(
"{} LogicCall event nonce {} last event nonce",
call.event_nonce,
last_event_nonce
);
if upcast(call.event_nonce) == last_event_nonce && event.block_number.is_some()
{
return event.block_number.unwrap();
}
}
Err(e) => error!("Got ERC20Deployed event that we can't parse {}", e),
}
}
Line by line:
for event in logic_call_executed_events {goes through the list of events one at a time, calling each oneevent.match LogicCallExecutedEvent::from_log(&event) {asks the parser to turn the raw event into a structured logic call object, and then chooses a branch based on whether that worked. The&eventpasses the event by reference, meaning the parser can read it without taking ownership of it.Ok(call) => {is the success branch: parsing worked and the result is namedcall.trace!(writes a low-level log message, useful for debugging."{} LogicCall event nonce {} last event nonce",is the message template, with two blanks to fill in.call.event_nonce,fills the first blank with the event's nonce.last_event_noncefills the second blank with the oracle's own record of the last nonce it has seen.);closes the log call.if upcast(call.event_nonce) == last_event_nonce && event.block_number.is_some()checks two things at once: whether this event's nonce matches the expected next one, and whether the event carries a block number. The&&means both must be true.{opens the block that runs when both conditions hold.return event.block_number.unwrap();hands the block number back to the caller as the answer.unwrap()extracts the value fromSome, which is safe here because the condition just checked that a value exists.}closes that inner block.}closes the success branch.Err(e) => error!("Got ERC20Deployed event that we can't parse {}", e),is the failure branch: if parsing returned an error, log it. Notice the message mentions an ERC20 deployed event, which looks like a copy-paste leftover, but that is not the main point.}closes thematch, and the final}closes theforloop.
The loop looks defensive: it matches on the Result returned by from_log and logs an error in the Err arm. What drew the researcher's attention was the implementation behind that call. LogicCallExecutedEvent::from_log is not implemented at all:
impl LogicCallExecutedEvent {
pub fn from_log(_input: &Log) -> Result<LogicCallExecutedEvent, GravityError> {
unimplemented!()
}
// snip...
}
Line by line:
impl LogicCallExecutedEvent {begins the section of code that defines behaviour for the logic call event type.pub fn from_log(_input: &Log) -> Result<LogicCallExecutedEvent, GravityError> {declares a public function namedfrom_log. It takes a raw log entry as input (the underscore in_inputsignals that the parameter is intentionally unused) and promises to return either a parsed event or aGravityError.unimplemented!()is the entire body. It is a placeholder that crashes the program the moment it runs.}closes the function, and the final}closes the definition block.// snip...indicates that other code was omitted from the excerpt.
Because the body is unimplemented!(), the function panics rather than returning an Err. The match in the caller therefore never gets a chance to handle the failure: the panic unwinds before the Err arm can run. The error handling in the loop gives a false sense of safety.
An everyday comparison: a receptionist is told "if the parcel cannot be delivered, fill in a returns form". The receptionist has a returns form ready. But the courier does not hand back an undeliverable parcel; the courier's van explodes. The form is never used, and the office stops working.
The researcher also noted that the same unimplemented function can be reached from check_for_events, at this line:
let logic_calls = LogicCallExecutedEvent::from_logs(&logic_calls)?;
Line by line:
let logic_calls =starts a variable to hold the parsed logic calls.LogicCallExecutedEvent::from_logs(&logic_calls)calls a plural version of the parser, which presumably parses a batch of events at once.?says: if this call returns an error, stop here and pass that error up to my caller.;ends the statement.
So there is more than one route into the panicking code. The ? handles a returned error, but it cannot catch a panic either, for the same reason as the match above.
Exploitation
The report does not lay out an exploitation sequence with requests or commands. The reasoning is about reachability of the code path: whenever the oracle processes a logic call event, from_log is invoked, and the process panics. The researcher's stated consequence is that attestations will be frozen until the code is patched, because the oracle cannot continue its work once it has crashed.
The report rates likelihood as high. The maintainer's response qualifies that: the issue is valid, but with zero probability at the time, because nothing on the module side currently triggers arbitrary logic. In other words, the code path exists and would crash the oracle, but the condition that produces logic call events was not being exercised.
To put the two views side by side:
| Question | Researcher's view | Maintainer's view |
|---|---|---|
| Is the code wrong? | Yes, the parser is a stub | Agreed, valid issue |
| Would it crash if reached? | Yes, the process panics | Not disputed |
| Can it be reached today? | Likelihood rated high | Zero probability, nothing triggers arbitrary logic |
| Consequence if reached | Attestations frozen until patched | Same consequence, but not currently reachable |
Root cause
The root cause is a stub implementation. LogicCallExecutedEvent::from_log is declared to return Result<LogicCallExecutedEvent, GravityError>, which invites callers to treat failure as a recoverable value, but its body is unimplemented!(), which panics. The caller in get_last_checked_block wraps the call in a match with an Err arm, which only handles a returned error, not a panic. The same applies to the ? at the from_logs call site in check_for_events: ? propagates a returned error, but cannot catch a panic. The existing error handling therefore does not defend against this failure mode.
A useful way to remember it: the function's signature makes a promise ("I will tell you if I fail") that its body does not keep ("I will crash instead"). Every caller written against the promise is misled.
Impact
If a logic call event is processed, the oracle panics and attestations stop until the code is patched. The maintainer confirmed the issue as valid while stating that it could not currently happen, since nothing on the module side triggers arbitrary logic. The practical impact is therefore conditional on logic call events actually being produced.
Fix
The recommendation in the report is to implement the method. The maintainer confirmed the issue as valid and described it as a good report despite the current impossibility of triggering it. The report does not describe a patch being applied.
Variants to test
If you want to look for similar problems in other code, these are the patterns to search for. Each one is a way of asking "is there a crash hiding behind something that looks like error handling?".
- Search bridge and oracle modules for other
unimplemented!(),todo!()orpanic!()bodies behind functions that returnResult. A positive result is a call site that matches on theResultor uses?, giving the appearance of error handling that a panic would bypass. - Look for event parsers that are registered by signature but whose decoding is incomplete. A positive result is an event signature included in a filter whose corresponding parser cannot actually run.
- Check every route into a stubbed function, not just the obvious one. Here the same function is reachable both from the per-event loop and from
from_logsinsidecheck_for_events. A positive result is more than one call site that can reach the panic. - Trace what happens to a long-running process when one of its parsing steps panics. A positive result is a loop or service that stops making progress entirely rather than skipping the bad item.
Hunting notes
This kind of bug hides in code that is scaffolded but not finished: event types declared, signatures registered and call sites wired up, while the decoder itself is a stub. During review, the signal is a function that returns Result but whose body is unimplemented!(), todo!() or an unconditional panic, especially when callers visibly handle errors. The second signal is a filter that subscribes to an event signature the code cannot yet parse. The researcher showed impact by tracing the path from the oracle's main loop through get_last_checked_block and check_for_events to the panicking function, and by stating the operational consequence: attestations frozen until patched. The maintainer accepted the report as valid while noting the trigger was not currently reachable.
Glossary
- Attestation: a formal statement by the bridge that an event really happened on the other chain; the receiving side relies on it before acting.
- Block: a numbered bundle of transactions recorded on a blockchain.
- Blockchain: a shared record book kept in copies by many computers, with entries grouped into linked blocks.
- Bridge: software that relays information or value between two blockchains.
- Cosmos: a blockchain network that Gravity Bridge connects to Ethereum.
- Ethereum: a blockchain network that Gravity Bridge connects to Cosmos.
- Event: a message a smart contract publishes to announce that something happened.
- Event signature: a short identifier used to filter for one kind of event.
- Function: a named block of code that performs one job and can be called from elsewhere.
- Gravity contract: the smart contract on Ethereum whose events the oracle watches.
- Nonce: a counter used once, here to number events so they can be ordered and checked for duplicates.
- Panic: an unrecoverable crash inside a program that ordinary error handling cannot catch.
?operator: Rust shorthand that passes a returned error up to the caller; it does not catch panics.- Result: a value that represents either success with an answer or failure with an error.
- Stub: a placeholder implementation that stands in for code not yet written.
unimplemented!(): a Rust placeholder that panics when executed, meaning the function has not been written yet.unwrap(): a Rust method that extracts the value from a success wrapper and panics if there is none.web3: the program's connection to the Ethereum network, used here to search for events.