Skip to content
DoS Audit finding Intermediate

Deadlock in submit_transaction()

The submit_transactions function reads and then writes a shared counter protected by a read-write lock, and under heavy load a thread can try to acquire the lock while already holding it, causing a panic. This could stall the sequencer and delay network transactions.

br0nz3p1ck4x3 Follow

Originally disclosed on Immunefi

Critical View original
  • Disclosed after under an hour

#43190 [BC-Critical] Deadlock in `submit_transaction()`

Submitted on Apr 3rd 2025 at 14:45:52 UTC by @br0nz3p1ck4x3 for Attackathon | Movement Labs

Description

Description

Inside submit_transactions(), the variable transactions_in_flight will be written and read to. In the following code-block, a read() is done:

Rust
let in_flight = {
			let transactions_in_flight = self.transactions_in_flight.read().unwrap();
			transactions_in_flight.get_count()
		};

A few lines below the read(), we can find write()

Rust
				{
					let mut transactions_in_flight = self.transactions_in_flight.write().unwrap();
					transactions_in_flight.increment(now, 1);
				}

The problem here is the dangerous usage of the read() and the write() methods. In Rust, a lock is placed during the read() and the write() operation. If the current thread attempts an access on a lock held by a current thread, this will cause a panic. We can see the following from the standard library

https://github.com/rust-lang/rust/blob/e0883a2a6c8e4afcb6e26a182885f687ba63a7f5/library/std/src/sync/poison/rwlock.rs#L441

Rust
	/// # Panics
    ///
    /// This function might panic when called if the lock is already held by the current thread.

As such, the submit_transaction() function is susceptible to a deadlock when it's under heavy load, which will lead to a panic and break the sequencer.

Impact

The deadlock will stall the sequencer, degrading the network performance and/or stalling the chain, depending on which sequencer is stalled.

Recommended Mitigation Steps

Use common patterns that eliminate the chance of deadlock when using read/write locks.

Proof of Concept

Proof of Concept

This proof of concept is straight-forward. This will happen under heavy workload because this will increase the chances of a thread trying to write/read at the same time.

Step one: Network is digested, sequencer_x is under heavy workload

Step two: thread_12 tries to read() the variable transactions_in_flight() while it still has a lock from a previous write() call.

Step three: A panic will happen, leading to a deadlock and stalling sequencer_x

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

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

Likely the code acquires a read lock and later a write lock on the same read-write lock within one function without releasing the first, so a thread can re-enter the lock and panic.

Impact

The deadlock could stall the sequencer, degrading network performance and potentially stalling the chain, depending on which sequencer is affected.

What the attacker needed

Heavy network load; sequencer under heavy workload

The fix

The code should be changed to use common patterns that eliminate the chance of deadlock when using read/write locks.

How it was found

  1. The network is busy and a sequencer is under heavy workload.
  2. A thread tries to read the transactions_in_flight counter while it still holds a lock from a previous write call.
  3. A panic occurs, leading to a deadlock and stalling the sequencer.

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 lock is like a key to a shared box: only one thread can hold it at a time. If a thread tries to take the key again while it already has it, the program crashes. Here the code takes the key to read a counter and then tries to take it again to update it, which can crash the sequencer under load.

What is DoS?

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

More by br0nz3p1ck4x3

View all

34 more disclosed reports, best first.

More from Movement Labs

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.