Skip to content
DoS Audit finding Intermediate

Garbage Collector can fail to run in a timely manner if building_time_ms is set to a low value

The garbage collector's interval calculation adds a fixed one second, so when the block building time is set below 500 ms the collector runs far less often than intended. This can leave stale transactions in the mempool, causing memory bloat and potentially a denial of service.

Cryptor Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

#42222 [BC-Insight] Garbage Collector can fail to run in a timely manner if building_time_ms is set to a low value

Submitted on Mar 21st 2025 at 19:56:48 UTC by @Cryptor for Attackathon | Movement Labs

Description

Brief/Intro

Garbage Collector can fail to run in a timely manner if building_time_ms is set to a low value

Vulnerability Details

In the following code, the function gc is essentially a garbage collector function

async fn gc(&self) -> Result<(), anyhow::Error> {
  
    
    let gc_interval = self.building_time_ms * 2 / 1000 + 1;
		let timestamp_threshold = SystemTime::now()
			.duration_since(UNIX_EPOCH)
			.unwrap()
			.as_secs()
			.saturating_sub(gc_interval);
		let gc_count = self.mempool.gc_mempool_transactions(timestamp_threshold).await?;
		if gc_count != 0 {
			info!("pruned {gc_count} transactions");
		} else {
			debug!("no transactions to prune")
		}
    
    tokio::time::sleep(Duration::from_secs(gc_interval)).await;
    Ok(())
}

After each gc run, the task goes to sleep for the duration of the gc_interval. The problem is that gc_interval essentially adds 1 second to the building_time_ms

let gc_interval = self.building_time_ms * 2 / 1000 + 1;

This mean that if the building_time_ms is set to a value low enough, ie. any value below 500, then the garbage collector will be unable to discard old transactions , potentially adding bloat to the mempool

Impact Details

Adding a second to the gc_interval can render the gc to be ineffective when the building time is set to a very low value.

References

https://github.com/immunefi-team/attackathon-movement/blob/a2790c6ac17b7cf02a69aea172c2b38d2be8ce00/protocol-units/sequencing/memseq/sequencer/src/lib.rs#L133-L149

Proof of Concept

Proof of Concept

For example, when building_time_ms is 400, the GC interval becomes 1000ms. This creates a window where transactions that should be garbage collected remain in the mempool longer than intended. Over time, this can lead to memory bloat and potential denial of service conditions as the GC runs less frequently than designed. Additionally, any building time less than 500ms will result in the same 1-second GC interval due to the integer division, making the GC unreliable for small building time values.

The original report as published on Immunefi, by Cryptor. 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 integer division plus a hard-coded '+ 1' in the interval calculation makes the garbage collector interval at least one second regardless of the configured building time.

Impact

Stale transactions may remain in the mempool longer than intended, which could lead to memory bloat and potential denial of service conditions.

What the attacker needed

Building_time_ms set below 500

The fix

The interval calculation should be corrected so that a low building time does not force a minimum one-second garbage collector interval.

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 task that removes old, unneeded items so memory does not fill up. Here the code that decides how often it runs adds one extra second, so with a very short block-building time the collector waits much longer than it should. Old transactions then pile up in the mempool, the waiting area for pending transactions, which can slow or crash the node.

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 Cryptor

View all

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