Skip to content
DoS Audit finding Intermediate

User can reuse sequence number causing DOS & breaking core invariant

A sequence number validation flaw allows a user to repeatedly submit transactions with sequence number 0, which are all accepted, breaking the uniqueness invariant. By submitting many such transactions with tiny gas price increases, an attacker can fill the in-flight transaction limit and cause a denial of service for all other transactions.

okmxuse Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

#42991 [BC-High] User can reuse sequence number causing DOS & breaking core invariant

Submitted on Mar 31st 2025 at 09:19:57 UTC by @okmxuse for Attackathon | Movement Labs

Description

Description

Whenever a transaction is processed, it is assigned a sequence number. This number is incremented within submit_transaction, specifically in has_invalid_sequence_number:

JavaScript
let min_used_sequence_number =
    if used_sequence_number > 0 { used_sequence_number + 1 } else { 0 };

To ensure sequence numbers remain unique for each transaction, they are incremented—however, this only occurs when used_sequence_number is greater than 0. This distinction is critical for the issue we outline below.

Later, the following check is performed:

JavaScript
if transaction.sequence_number() < min_sequence_number {
    info!("Transaction sequence number too old: {:?}", transaction.sequence_number());
    return Ok(SequenceNumberValidity::Invalid((
        MempoolStatus::new(MempoolStatusCode::InvalidSeqNumber),
        Some(DiscardedVMStatus::SEQUENCE_NUMBER_TOO_OLD),
    )));
}

This ensures that transactions with outdated sequence numbers are rejected.

Issue

A user can repeatedly submit transactions with a sequence number of 0 because they are not incremented. Thus meaning that nodes will now process transactions with reused sequence numbers which breaks a core invariant.

Additionally, this loophole allows a user to DOS all transactions by reaching the inflight_limit.This can be achieved by repeatedly submitting gas increase transactions, bloating the inflight transactions. We will further showcase this in the POC

Impact

Due to this issue users are able to DOS the chain & break a core invariant.

Recommendation

Disallow users to cause a DOS and ensure that this core invariant remains intact.

Proof of Concept

POC

  • paste the following test-function inside transaction_pipe.rs. Feel free to read the commentary for more context:
JavaScript
	async fn test_repeat_submit_with_seq0() -> Result<(), anyhow::Error> {
// We will showcase 2 scenarios
// - Scenario 1: Repeatedly calls made with seq 0, will all be accepted showcasing bug
// - Scenario 2: Repeatedly calls made with seq 1, only first will be accepted

let maptos_config = Config::default();
let (_context, mut transaction_pipe, _tx_receiver, _tempdir) = setup().await;

// Scenario 1:
let user_transaction = create_signed_transaction(0, &maptos_config);
let (mempool_status, _) = transaction_pipe.submit_transaction(user_transaction).await?;
assert_eq!(mempool_status.code, MempoolStatusCode::Accepted);

let user_transaction = create_signed_transaction(0, &maptos_config);
let (mempool_status, _) = transaction_pipe.submit_transaction(user_transaction).await?;
assert_eq!(mempool_status.code, MempoolStatusCode::Accepted);

let user_transaction = create_signed_transaction(0, &maptos_config);
let (mempool_status, _) = transaction_pipe.submit_transaction(user_transaction).await?;
assert_eq!(mempool_status.code, MempoolStatusCode::Accepted);

let user_transaction = create_signed_transaction(0, &maptos_config);
let (mempool_status, _) = transaction_pipe.submit_transaction(user_transaction).await?;
assert_eq!(mempool_status.code, MempoolStatusCode::Accepted);

// Scenario 2:
let user_transaction = create_signed_transaction(1, &maptos_config);
let (mempool_status, _) = transaction_pipe.submit_transaction(user_transaction).await?;
assert_eq!(mempool_status.code, MempoolStatusCode::Accepted);

let user_transaction = create_signed_transaction(1, &maptos_config);
let (mempool_status, _) = transaction_pipe.submit_transaction(user_transaction).await?;
assert_eq!(mempool_status.code, MempoolStatusCode::InvalidSeqNumber);

		Ok(())
	}
  • Run nix develop -c cargo test test_repeat_submit_with_seq0
  • Logs
running 1 test
test background::transaction_pipe::tests::test_repeat_submit_with_seq0 ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 15 filtered out; finished in 3.64s

With this POC in mind we will now focus on the aforementioned statement:

Additionally, this loophole allows a user to cause a denial-of-service (DoS) attack by reaching the inflight_limit. This can be achieved by repeatedly submitting gas increase transactions, causing the number of inflight transactions to rise. We will further showcase this in the POC

This is possible because inflight transactions are only incremented when status.code returns Accepted.

JavaScript
	match status.code {
			MempoolStatusCode::Accepted => {
//..code
				// increment transactions in flight
				{
					let mut transactions_in_flight = self.transactions_in_flight.write().unwrap();
					transactions_in_flight.increment(now, 1);
				}

A user can exploit this by repeatedly submitting transactions with sequence number 0 while increasing the gas amount by a super small amount. These transactions are then recognized as gas increase transactions and return as Accepted

Note that we have highlighted only the relevant code. Please refer to the full commentary for additional context:

JavaScript
pub(crate) fn insert(&mut self, txn: MempoolTransaction) -> MempoolStatus {
    let address = txn.get_sender();
    let txn_seq_num = txn.sequence_info.transaction_sequence_number;
    let acc_seq_num = txn.sequence_info.account_sequence_number;

    // If the transaction is already in Mempool, we only allow the user to
    // increase the gas unit price to speed up a transaction, but not the max gas.

    // These if statements ensure the sequence number is the same so that it is recognized as a gas increasing tx 
    if let Some(txns) = self.transactions.get_mut(&address) {
        if let Some(current_version) = txns.get_mut(&txn_seq_num) {

            // Here, it checks if the new gas price is higher
        } else if current_version.get_gas_price() < txn.get_gas_price() {
            // Update the transaction if the new gas price is higher
            if let Some(txn) = txns.remove(&txn_seq_num) {
                self.index_remove(&txn);
            };
            // `Accepted` is returned
            MempoolStatus::new(MempoolStatusCode::Accepted)
        }
    }
}

A user can exploit this mechanism to trigger the inflight_limit check, effectively causing a DOS for all transactions.

The only requirement for the user is to pay gas fees. However, they can bypass this cost barrier by increasing the gas price in small, negligible increments in combination with Aptos' low fee prices.

The original report as published on Immunefi, by okmxuse. 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 minimum sequence number calculation only increments when the used sequence number is greater than zero, leaving zero as a permanently valid value that is never advanced.

Impact

An attacker could cause a denial of service by filling the in-flight transaction limit, preventing other transactions from being processed, and break the core invariant that sequence numbers are unique.

What the attacker needed

Ability to submit transactions; pay gas fees (can be minimised)

The fix

The sequence number validation should be corrected so that sequence number 0 is not permanently reusable, for example by always incrementing the minimum sequence number after a transaction is processed.

How it was found

  1. Create a signed transaction with sequence number 0.
  2. Submit it to the transaction pipe and observe it is accepted.
  3. Repeat submitting transactions with sequence number 0 multiple times; all are accepted.
  4. To cause denial of service, repeatedly submit transactions with sequence number 0 while increasing the gas price by a tiny amount, so they are treated as gas increase transactions and accepted.
  5. The in-flight transaction count increases with each accepted transaction until the inflight limit is reached, blocking other transactions.

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.

Every transaction has a sequence number that should be unique and increase over time. The code only increments the minimum allowed sequence number when the previous used number is greater than zero, so zero is never incremented. This lets someone send many transactions with the same number zero, and the system accepts them all, which can clog the network.

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 okmxuse

View all

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