Skip to content
Business logic Audit finding Intermediate

Values of the current gc_slot can be garbage collected in edge case

The garbage collector for in-flight transactions can remove the current slot when the time-to-live divided by the slot duration rounds down to zero. This causes unexpired transactions to be dropped, allowing more transactions to be submitted than intended.

HollaDieWaldfee Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

#41978 [BC-Insight] Values of the current gc_slot can be garbage collected in edge case

Submitted on Mar 19th 2025 at 18:30:52 UTC by @HollaDieWaldfee for Attackathon | Movement Labs

Description

Brief/Intro

When the transactions in flight are garbage collected, values that have expired should be removed. But in certain cases, this even removes values of the current gc_slot that have not expired yet and have just been added.

Vulnerability Details

Let's take a look at how this happens.

Every time a transaction is received and added to the mempool, the transactions in flight are garbage collected, if enough time has passed after the last time they have been garbage collected. This can be verified by taking a look at reference (1).

Inside of gc(), all slots that are too old are removed. However, if self.value_ttl.get() / self.gc_slot_duration.get() rounds down to zero, the current slot will be removed as well even though it has not expired yet.

As a result, values that have not expired will be garbage collected.

In contrast, the garbage collector for the used_sequence_number_pool correctly only removes slots until the current one. To verify this, please take a look at reference (4). Given this difference to reference (4), the garbage collection for in-flight transactions is clearly flawed and does not meet the security guarantees - that the current slot can't be removed - that the sequence number garbage collector meets.

Impact Details

Values that have not expired will be garbage collected. Hence, the amount of transactions in flight will be lower than it should and more transactions are allowed to be submitted.

References

(1): https://github.com/immunefi-team/attackathon-movement/blob/a2790c6ac17b7cf02a69aea172c2b38d2be8ce00/protocol-units/execution/maptos/opt-executor/src/background/transaction\\_pipe.rs#L140-L153\\ (2): https://github.com/immunefi-team/attackathon-movement/blob/a2790c6ac17b7cf02a69aea172c2b38d2be8ce00/util/collections/src/garbage/counted.rs#L70-L71\\ (3): https://github.com/immunefi-team/attackathon-movement/blob/a2790c6ac17b7cf02a69aea172c2b38d2be8ce00/util/collections/src/garbage/counted.rs#L72-L76\\ (4): https://github.com/immunefi-team/attackathon-movement/blob/a2790c6ac17b7cf02a69aea172c2b38d2be8ce00/protocol-units/execution/maptos/opt-executor/src/gc\\_account\\_sequence\\_number.rs#L79-L84

Proof of Concept

Proof of Concept

  1. A new transaction is received and successfully submitted. transactions_in_flight.gc() is called since self.last_gc.elapsed() >= GC_INTERVAL. Again, this can be verified by taking a look at reference (1).
  2. As showcased in reference (2), this function calculates the slot_cutoff in the following way: gc_slot.saturating_sub(self.value_ttl.get() / self.gc_slot_duration.get()). If self.value_ttl.get() / self.gc_slot_duration.get() rounds down to zero, the slot_cutoff will be the current gc_slot. This means that only the slots after the cutoff will be kept and all of the other slots, including the current slot, wll be removed (reference (3)).
  3. Now, the current slot will be removed even though it has not expired yet. As a result, the amount of transactions in flight will be decreased by too much and allows more transactions to be submitted than it should.

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 an integer division rounding down to zero in the slot cutoff calculation, causing the current slot to be included in the removal range.

Impact

The amount of transactions in flight could be lower than intended, allowing more transactions to be submitted than the system should permit.

What the attacker needed

Value_ttl / gc_slot_duration rounds down to zero; garbage collection interval has elapsed

The fix

The garbage collection logic should be changed to only remove slots strictly before the current slot, similar to the sequence number garbage collector.

How it was found

  1. A new transaction is received and successfully submitted, triggering garbage collection of in-flight transactions.
  2. The garbage collector calculates the slot cutoff by subtracting the integer division of value TTL by slot duration from the current slot.
  3. If that division rounds down to zero, the cutoff equals the current slot, so the current slot is removed along with older ones.
  4. As a result, unexpired transactions are dropped and the in-flight count is reduced, allowing more transactions to be submitted.

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 garbage collector is a background process that removes old, expired data to free up space. Here, a calculation mistake can cause it to also delete the most recent data that has not expired yet. This means the system thinks there are fewer transactions waiting than there actually are, so it lets more new transactions in than it should.

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.