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.
Originally disclosed on Immunefi
- 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
- Report ID: #41978
- Report Type: Blockchain/DLT
- Report severity: Insight
- Target: https://github.com/immunefi-team/attackathon-movement/tree/main/util/collections
- Impacts:
- Causing network processing nodes to process transactions from the mempool beyond set parameters
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
- A new transaction is received and successfully submitted.
transactions_in_flight.gc()is called sinceself.last_gc.elapsed() >= GC_INTERVAL. Again, this can be verified by taking a look at reference (1). - As showcased in reference (2), this function calculates the
slot_cutoffin the following way:gc_slot.saturating_sub(self.value_ttl.get() / self.gc_slot_duration.get()). Ifself.value_ttl.get() / self.gc_slot_duration.get()rounds down to zero, theslot_cutoffwill be the currentgc_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)). - 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.
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
- A new transaction is received and successfully submitted, triggering garbage collection of in-flight transactions.
- The garbage collector calculates the slot cutoff by subtracting the integer division of value TTL by slot duration from the current slot.
- If that division rounds down to zero, the cutoff equals the current slot, so the current slot is removed along with older ones.
- 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.