Skip to content
DoS Audit finding Intermediate

Potential unhandled panic in protocol-units::execution::maptos::opt-executor::executor/mod::decrement_transactions_in_flight

The decrement_transactions_in_flight function calls unwrap on a write lock without handling the case where the lock is poisoned. If the lock is poisoned, the node will panic, causing downtime that affects RPC and API calls.

p4rsely Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

#43148 [BC-Medium] Potential unhandled panic in protocol-units::execution::maptos::opt-executor::executor/mod::decrement_transactions_in_flight

Submitted on Apr 2nd 2025 at 20:00:53 UTC by @p4rsely for Attackathon | Movement Labs

Description

Brief/Intro

In Rust the unwrap function expects either a Option value or Err, this needs to be handled gracefully. If unwrap() receives an unhandled Err the rust code will panic.

Vulnerability Details

In the mod.rs file in protocol-units/execution/maptos/opt-executor/src/executor/mod.rs there is a function called decrement_transactions_in_flight which has no return value which means any errors are not caught by the anyhow errors. The code further calls the unwrap function without handling any potential return Err's, using one of the rust error handling strategies like eg: match.

In the line :

Rust
// unwrap because lock is poisoned
let mut transactions_in_flight = self.transactions_in_flight.write().unwrap();

There is an attempt to get a lock on the variable transactions_in_flight which is of type Arc<RwLock<GcCounter>> using the write call. There is an added comment about using unwrap to catch any poisoned locks. However merely using unwrap will not cause the code not to panic. Should the lock be poisoned the code will panic as shown in the test created for the PoC.

Impact Details

Should the lock be poisoned it would be best to handle the error gracefully and try to correct it without causing the node to painc.
A panic will cause downtime for the node which can impact RPC and API calls.

References

https://github.com/movementlabsxyz/movement/blob/main/protocol-units/execution/maptos/opt-executor/src/executor/mod.rs#L135-L146

Proof of Concept

Proof of Concept

Please add this test to the file protocol-units/execution/maptos/opt-executor/src/executor/execution.rs

Rust
#[tokio::test]
	async fn test_poisoned_lock() -> Result<(), anyhow::Error> {
		let private_key = Ed25519PrivateKey::generate_for_testing();
		let (tx_sender, _tx_receiver) = mpsc::channel(16);
		let (executor, _tempdir) = Executor::try_test_default(private_key).await?;
		let (context, _transaction_pipe) = executor.background(tx_sender)?;
		let service = Service::new(&context);
		{
			let transactions_in_flight_clone = Arc::clone(&executor.transactions_in_flight);
			std::thread::spawn(move || {
				let _lock = transactions_in_flight_clone.write().unwrap();
				panic!("Simulating a panic this will poison the lock");
			})
			.join()
			.expect_err("Thread did not panic as expected");
		}

		executor.decrement_transactions_in_flight(1);
		Ok(())
	}

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

The code uses unwrap on a poisoned lock instead of handling the error gracefully.

Impact

A poisoned lock could cause the node to panic, leading to downtime that may affect RPC and API calls.

What the attacker needed

A poisoned lock

The fix

The code should handle the poisoned lock error gracefully, for example with a match, instead of calling unwrap.

How it was found

  1. Create a test that spawns a thread which takes the write lock and then panics, poisoning the lock.
  2. Join the thread and confirm it panicked.
  3. Call decrement_transactions_in_flight on the executor.

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 a way for one part of a program to stop other parts from using the same data at the same time. If a thread crashes while holding the lock, the lock becomes 'poisoned' and later attempts to use it can fail. Here the code assumes the lock will always work and crashes the whole node if it does not.

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 p4rsely

View all

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