Skip to content
Business logic Audit finding Intermediate

Incomplete transaction decrementing leading to undesired behaviour

The transaction decrementing function in the Movement node fails to account for all transactions when some lifetime slots are zero, leaving a remainder unprocessed. This can cause inconsistencies in transaction tracking and block processing, though no direct funds are at risk.

okmxuse Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

#41023 [BC-Insight] Incomplete transaction decrementing leading to undesired behaviour

Submitted on Mar 9th 2025 at 16:56:43 UTC by @okmxuse for Attackathon | Movement Labs

Description

Description

Inside process_block_from_da, transactions are retrieved and decremented by calling decrement_transactions_in_flight:

JavaScript
let transactions_count = block.transactions().len();
let span = info_span!(target: "movement_timing", "execute_block", id = ?block_id);
let commitment =
    self.execute_block_with_retries(block, block_timestamp).instrument(span).await?;

// Decrement the number of transactions in flight on the executor
self.executor.decrement_transactions_in_flight(transactions_count as u64);

This function then calls decrement:

JavaScript
pub fn decrement(&mut self, mut value: u64) {
    // Iterate over each slot
    for lifetime in self.value_lifetimes.values_mut() {
        if *lifetime > 0 {
            // Determine how much to decrement, ensuring it doesn't go below zero
            let decrement_amount = value.min(*lifetime);
            *lifetime -= decrement_amount;
            // Reduce the remaining value by what was actually decremented
            value -= decrement_amount;

            // If no remaining value to decrement, exit early
            if value == 0 {
                break;
            }
        }
    }
}

Here, transactions are decremented only when *lifetime is greater than 0. If no transactions are left, the function exits early. However, there is an edge case where no non-empty slots remain, yet some transactions remain unprocessed.

Impact

The remaining 2 transactions are neither decremented nor accounted for anywhere else, they are simply forgotten while the function moves on. This can lead to inconsistencies in transaction handling, potentially causing mismatches in block processing. The block might include these transactions while they remain untracked due to improper decrementing.

For example, the logging statement indicates that 10 transactions are being decremented, but in reality, only 8 have been processed.

JavaScript
		info!(
			target: "movement_timing",
			count,
			current,
			"decrementing_transactions_in_flight",
		);
	

Recommendation

We would recommend handling such edge cases that could lead to mismatch of processed transactions when decrementing.

Proof of Concept

POC

Consider the following scenario:

  1. decrement_transactions_in_flight is called with transactions_count = 10.
  2. decrement is called with value = 10.
  3. There are two lifetimes: one with a value of 8 and another with 0.
  4. The first loop executes:
JavaScript
for lifetime in self.value_lifetimes.values_mut() {
    // Entering the loop since lifetime is 8
    if *lifetime > 0 {
        // decrement_amount is 8
        let decrement_amount = value.min(*lifetime);
        // *lifetime becomes 0
        *lifetime -= decrement_amount;
        // value becomes 2
        value -= decrement_amount;

        // value != 0, so continue looping
        if value == 0 {
            break;
        }
    }
}
  1. The second loop iteration begins, but since the second *lifetime is 0, the loop is skipped, and the function returns.
JavaScript
// this will not execute this lifetime is 0
if *lifetime > 0 {

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 decrement loop skips slots with zero lifetime and exits early when the remaining value is zero, but does not handle the case where the total lifetime across all slots is less than the value to decrement.

Impact

The remaining transactions are not decremented or tracked, which could lead to inconsistencies in transaction handling and block processing, though no direct funds are at risk.

What the attacker needed

None

The fix

The edge case should be handled to ensure all transactions are properly decremented or accounted for.

How it was found

  1. Call decrement_transactions_in_flight with transactions_count = 10.
  2. decrement is called with value = 10.
  3. There are two lifetimes: one with value 8 and another with 0.
  4. The first loop processes the lifetime of 8, reducing value to 2.
  5. The second loop iteration is skipped because the second lifetime is 0, and the function returns without decrementing the remaining 2.

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.

This report is about a bug in a blockchain node's code that keeps track of how many transactions are waiting to be processed. The code is supposed to reduce a counter by the number of transactions in a block, but if some internal slots are already zero, it stops early and forgets to subtract the rest. That means the system's count of pending transactions can become wrong, which might cause confusion later.

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

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.