Skip to content
Business logic Audit finding Intermediate

The call to commit_transaction() includes the wrong sequence number

The commit_transaction function is called with the account's current sequence number instead of one less, causing it to delete transactions with sequence numbers up to and including the current one. This can prematurely remove valid transactions from the mempool.

HollaDieWaldfee Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

#43303 [BC-Medium] The call to `commit_transaction()` includes the wrong sequence number

Submitted on Apr 4th 2025 at 12:16:17 UTC by @HollaDieWaldfee for Attackathon | Movement Labs

Description

Brief/Intro

When a new transaction is submitted, commit_transaction() is called with the account's sequence number. However, commit_transaction() should be called with account_sequence_number - 1 instead such that all transactions with sequence number < account_sequence_number will be deleted.

Vulnerability Details

When a transaction gets accepted, commit_transaction() is called to handle the transaction commit. This includes deleting all transactions with a lower sequence number. However, the call to commit_transaction() is done with the current account's sequence number.

Rust
    pub fn commit_transaction(&mut self, account: &AccountAddress, sequence_number: u64) {
        let current_seq_number = self.get_sequence_number(account).map_or(0, |v| *v);
        let new_seq_number = max(current_seq_number, sequence_number + 1);
        self.sequence_numbers.insert(*account, new_seq_number);
        self.clean_committed_transactions(account, new_seq_number);
        self.process_ready_transactions(account, new_seq_number);
    }

As a result, clean_committed_transactions() will be called with account_sequence_number + 1 which means that all transactions with sequence number <= account_sequence_number will be deleted. But the current account_sequence_number is already a new sequence number which means that it should not be deleted. And in process_ready_transactions(), the mempool can prematurely delete the transaction with sequence_number.

The solution is to call the commit_transaction() function with sequence_number - 1 when the sequence number is greater than 0, and to not call commit_transaction() at all when sequencer number is equal to 0.

Impact Details

Commiting a new transaction deletes too many transactions.

Although Immunefi classifies the impact of "Causing network processing nodes to process transactions from the mempool beyond set parameters" as a High severity issue, and we submit the issue with High severity according to Immunefi rules, we believe that it should be Low severity.

References

(1): https://github.com/immunefi-team/attackathon-movement/blob/a2790c6ac17b7cf02a69aea172c2b38d2be8ce00/protocol-units/execution/maptos/opt-executor/src/background/transaction\\_pipe.rs#L299

(2): https://github.com/immunefi-team/attackathon-movement-aptos-core/blob/627b4f9e0b63c33746fa5dae6cd672cbee3d8631/mempool/src/core\\_mempool/transaction\\_store.rs#L496-L502

Proof of Concept

Proof of Concept

  1. submit_transaction() is called which calls commit_transaction() with the account's sequence number when the submitted transaction gets accepted (reference (1)).
  2. Inside of this function, the sequence number gets incremented by 1 and then clean_committed_transactions() gets called with the incremented sequence number (reference (2)). As a result, all transactions with sequence number <= account_sequence_number will be deleted.

The original report as published on Immunefi, by HollaDieWaldfee. 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 caller passes the account's current sequence number to commit_transaction instead of sequence_number - 1, so the cleanup logic deletes the current transaction as well.

What the attacker needed

None

The fix

The commit_transaction function should be called with sequence_number - 1 when the sequence number is greater than 0, and not called at all when the sequence number is 0.

How it was found

  1. A transaction is submitted and accepted, triggering commit_transaction with the account's sequence number.
  2. Inside commit_transaction, the sequence number is incremented by one and clean_committed_transactions is called with the incremented value.
  3. As a result, all transactions with sequence number less than or equal to the account's sequence number are deleted.

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 sequence number is like a ticket number for transactions from the same account; they must be processed in order. The code mistakenly treats the current ticket as already used, so it throws away that transaction and any earlier ones still waiting. This can make valid transactions disappear before they are processed.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by HollaDieWaldfee

View all

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

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.