Skip to content
DoS Audit finding Intermediate

Unbounded snappy decompression in NetworkPayloadEnvelope::decode_v1..v4 leads to per-node memory exhaustion reachable from any unauthenticated P2P peer

The four NetworkPayloadEnvelope decode functions pass attacker-supplied gossip data to snappy decompression without checking the claimed decompressed length, so a tiny message can request a multi-gigabyte allocation. Any unauthenticated P2P peer could send such a message to connected nodes, causing memory exhaustion and, on some platforms, process termination.

imbanytui Follow

Originally disclosed on Immunefi

Critical View original
  • Disclosed after under an hour

75554 bc critical unbounded snappy decompression in networkpayloadenvelope decode v1 v4 leads to per node memory exhaustion reachable from any unauthenticated p2p peer

Submitted on Apr 29th 2026 at 18:39:52 UTC by @imbanytui for Audit Comp | Base Azul

  • Report ID: #75554
  • Report Type: Blockchain/DLT
  • Report severity: Critical
  • Target: https://github.com/base/base/tree/v0.8.0-rc.28
  • Impacts:
    • Increasing network processing node resource consumption by at least 30% without brute force actions, compared to the preceding 24 hours
    • Direct loss to Base or users ≥ 10% of funds held within Bridge.

Description

Brief/Intro

In the audited release base/base @ v0.8.0-rc.28, the four NetworkPayloadEnvelope::decode_v* functions in crates/common/rpc-types-engine/src/envelope.rs (decode_v1, decode_v2, decode_v3, decode_v4) call snap::raw::Decoder::decompress_vec(data) without first validating the snappy header's claimed decompressed length. The decoder pre-allocates a Vec<u8> of the size the attacker-controlled header claims — up to ~4 GiB from a 5-byte input — before reading any compressed bytes. These functions are invoked on every gossipsub block-topic message received over P2P, with no authentication or rate-limiting on the message source. In production this means any peer in the Base gossip network can cause a node it is connected to to attempt a 4 GiB allocation per malicious message; on Windows, macOS, and Linux without memory overcommit, that allocation request is rejected by the OS allocator, terminating the affected node's process.

Vulnerability Details

The buggy function shape is identical across all four version variants. From crates/common/rpc-types-engine/src/envelope.rs:255-258 (decode_v1; decode_v2 at lines 299/302, decode_v3 at lines 343/346, decode_v4 at lines 399/402 share the same shape):

Rust
pub fn decode_v1(data: &[u8]) -> Result<Self, PayloadEnvelopeError> {
    use ssz::Decode;
    let mut decoder = snap::raw::Decoder::new();
    let decompressed = decoder.decompress_vec(data)?;     // unbounded pre-allocation

    if decompressed.len() < 66 {
        return Err(PayloadEnvelopeError::InvalidLength);
    }
    // ...
}

The behavior of snap::raw::Decoder::decompress_vec is to read the snappy stream's leading varint, interpret it as the claimed decompressed length, and pre-allocate a Vec<u8> of exactly that size before decompressing the body. Maximum varint value is 2^32 - 1 ≈ 4 GiB. A minimal 5-byte input encoding 0xFFFFFFFF (bytes [0xFF, 0xFF, 0xFF, 0xFF, 0x0F]) is sufficient to trigger a 4 GiB pre-allocation request.

The functions are reached on every block gossip message via BlockHandler::handle at crates/consensus/gossip/src/handler.rs:50-58:

Rust
fn handle(&mut self, msg: Message) -> (MessageAcceptance, Option<NetworkPayloadEnvelope>) {
    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)
    } else if msg.topic == self.blocks_v3_topic.hash() {
        NetworkPayloadEnvelope::decode_v3(&msg.data)
    } else if msg.topic == self.blocks_v4_topic.hash() {
        NetworkPayloadEnvelope::decode_v4(&msg.data)
    } // ...

Note that MAX_GOSSIP_SIZE = 10 * (1 << 20) (= 10 MiB) is defined at crates/consensus/gossip/src/config.rs:15, but this limit applies to the compressed payload size, not to the claimed decompressed length encoded in the snappy header. A 5-byte compressed payload trivially passes the 10 MiB gossip-size check while claiming 4 GiB decompressed.

The Go reference implementation op-node (used by upstream Optimism) explicitly bounds the decompression length before calling the decoder, via a snappy.DecodedLen(msg.Data) check against maxValidationSize prior to invoking snappy.Decode. The Base Rust port omits this check across all four decode_v* variants — this is an inconsistency with the documented op-stack reference behavior, not an intentional design difference.

Impact Details

This vulnerability maps directly onto two of the program's explicitly listed in-scope Medium-tier Blockchain/DLT impacts:

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

A single 5-byte gossip message forces a 4 GiB pre-allocation. This represents a >30,000% spike in per-node memory consumption relative to baseline gossip traffic (individual gossip messages are typically a few KB compressed). The trigger is a single message — there is no flooding, no repetition, no amplification — satisfying the "without brute force actions" qualifier. On Linux systems with overcommit enabled (where the allocation is not immediately rejected by the OS), the per-node virtual-address-space consumption still grows linearly with malicious-message volume, comfortably meeting the ≥30% threshold against any reasonable 24-hour baseline.

Impact 2 — "Shutdown of greater than 10% or equal to but less than 30% of network processing nodes without brute force actions, but does not shut down the network."

On Windows, macOS, and Linux with vm.overcommit_memory=2 configured (the latter being a recommended hardened configuration for production validators), the OS allocator immediately rejects the 4 GiB request, causing the host process to terminate on the Vec::with_capacity failure path. A peer that joins the libp2p gossipsub mesh of N other peers (default mesh degree D = 6–12 in libp2p-gossipsub) can cause termination of those connected peers by sending one malicious payload to each — a single-message-per-target operation. By using multiple peer identities (each connecting to a fresh subset of the mesh), the attacker reaches >10% but <30% of operating validators without any flooding or amplification — directly matching the second listed Medium impact. Gossip relay does NOT amplify the issue, because the malicious payload terminates the receiving validator process before relay would occur — keeping the impact bounded and outside the "total network shutdown" Critical tier.

PoC compliance with program rules: the accompanying Proof of Concept is a self-contained Rust unit test that runs against the affected library code in isolation. No execution is performed against any project asset (mainnet, Sepolia testnet, deployed Base infrastructure, or any other live system). This is a code-level vulnerability disclosure compliant with the program rule prohibiting "denial of service attacks executed against project assets".

References

Link to Proof of Concept

https://gist.github.com/imbanytuidoter/5cf04fb4537c59220bcb29c4cb9e80fa

Proof of Concept

Step-by-step exploit walkthrough

Reproduction does not require any execution against project assets. The vulnerability is in the library code path NetworkPayloadEnvelope::decode_v1..v4 → snap::raw::Decoder::decompress_vec and is fully reproducible against the audited release base/base @ v0.8.0-rc.28 in isolation.

{% stepper %} {% step %}

Step 1 — Attacker constructs a 5-byte malicious snappy frame

The snappy stream format begins with a varint encoding the claimed decompressed length. The maximum varint value (2^32 - 1 = 4,294,967,295, ~4 GiB) encodes as five bytes: [0xFF, 0xFF, 0xFF, 0xFF, 0x0F]. No additional compressed payload is required for the attack — the decoder commits to the allocation BEFORE reading the body.

malicious_input = [0xFF, 0xFF, 0xFF, 0xFF, 0x0F]   // 5 bytes total
                   └────── varint = 0xFFFFFFFF ──────┘
                   claimed decompressed length: ~4 GiB

{% endstep %}

{% step %}

Step 2 — Attacker publishes this 5-byte payload to any Base block-topic gossipsub topic

Base's libp2p gossipsub configuration allows any peer that completes the standard libp2p handshake to publish to the block topics. There is no signed-publisher restriction at the gossip layer (block-level signature validation happens AFTER the envelope decodes — and the bug fires DURING decoding). The attacker publishes one message per target peer to topics blocks_v1, blocks_v2, blocks_v3, or blocks_v4 (any of the four — all four decode_v* are equally affected).

The compressed message size (5 bytes) trivially passes the 10 MiB MAX_GOSSIP_SIZE check at crates/consensus/gossip/src/config.rs:15, because that check applies to the compressed payload size, not the claimed decompressed length encoded in the snappy header. {% endstep %}

{% step %}

Step 3 — Receiving node dispatches the message to the affected envelope decoder

BlockHandler::handle at crates/consensus/gossip/src/handler.rs:50-58 matches the message topic and calls one of:

Rust
NetworkPayloadEnvelope::decode_v1(&msg.data)   // for blocks_v1 topic
NetworkPayloadEnvelope::decode_v2(&msg.data)   // for blocks_v2 topic
NetworkPayloadEnvelope::decode_v3(&msg.data)   // for blocks_v3 topic
NetworkPayloadEnvelope::decode_v4(&msg.data)   // for blocks_v4 topic

msg.data here is the attacker's 5-byte payload, unmodified. {% endstep %}

{% step %}

Step 4 — decode_v* invokes snap::raw::Decoder::decompress_vec(data) without bound check

The body of every decode_v* function (lines 258 / 302 / 346 / 402 of envelope.rs) is:

Rust
pub fn decode_v1(data: &[u8]) -> Result<Self, PayloadEnvelopeError> {
    use ssz::Decode;
    let mut decoder = snap::raw::Decoder::new();
    let decompressed = decoder.decompress_vec(data)?;     // ← here
    if decompressed.len() < 66 {
        return Err(PayloadEnvelopeError::InvalidLength);
    }
    // ...
}

The snap crate's decompress_vec is documented to first read the varint header to determine the claimed length, then allocate a destination Vec of exactly that size, then decompress into it. With our malicious 5-byte input, the call attempts Vec::with_capacity(0xFFFFFFFF) BEFORE encountering any error in the (empty) compressed body. {% endstep %}

{% step %}

Step 5 — The 4 GiB allocation request hits the OS allocator

Target platform Result
Linux with overcommit (default vm.overcommit_memory=0) Virtual address space reservation succeeds; physical memory is not consumed until written. Multiple repeated requests across messages exhaust virtual mapping limits → gradual resource consumption increase, satisfying Impact 1.
Linux with overcommit disabled (vm.overcommit_memory=2) Allocator immediately rejects → process terminates on Vec::with_capacity panic → satisfies Impact 2 (per-node shutdown).
macOS Allocator rejects → process terminates → satisfies Impact 2.
Windows Allocator rejects (commit fails) → process terminates → satisfies Impact 2.
{% endstep %}

{% step %}

Step 6 — Attacker scales the attack to multiple peers without any brute-force amplification

The attacker is connected to N other peers via the libp2p gossipsub mesh (default mesh degree D = 6–12). Sending the same 5-byte payload to each connected peer (one message per peer, no flooding) terminates each peer that has the hardened OS allocator configuration. By using multiple peer identities (each connecting to a fresh subset of the mesh), the attacker reaches a percentage of the total validator population matching Impact 2's "greater than 10% but less than 30%" threshold. {% endstep %} {% endstepper %}

Reference: self-contained Rust unit test

A self-contained Rust unit test reproducing Steps 1, 4, and 5 against the upstream snap crate (the exact dependency the production code links against) is included with this submission. The test uses only the public snap = "1.1" API, takes ~120 lines of Rust, and runs in isolation with no network or project asset interaction:

Rust
// poc/tests/snappy_bomb.rs (excerpt)

use snap::raw::{decompress_len, Decoder};

const MALICIOUS_INPUT: &[u8] = &[0xFF, 0xFF, 0xFF, 0xFF, 0x0F];

#[test]
fn claimed_length_demonstration() {
    // decompress_len reads only the varint header — no allocation.
    let claimed = decompress_len(MALICIOUS_INPUT).expect("varint decodes");
    assert_eq!(claimed, 0xFFFFFFFF);  // 4 GiB - 1 claimed
    assert!(claimed > 4_000_000_000);
}

#[test]
fn unbounded_decompress_vec_attempts_4gb_allocation() {
    // EXACT call sequence from envelope.rs decode_v1:
    let mut decoder = Decoder::new();
    let result = decoder.decompress_vec(MALICIOUS_INPUT);
    // On constrained CI: result is Err (alloc rejected).
    // On overcommit Linux: result is Ok with VmPeak spike of ~4 GiB.
    // Both outcomes confirm: alloc-before-validate.
    let _ = result;
}

#[test]
fn fix_demonstration_decompress_len_is_cheap_and_safe() {
    const MAX_GOSSIP_SIZE: usize = 10 * 1024 * 1024; // 10 MiB
    let claimed = decompress_len(MALICIOUS_INPUT).expect("varint decodes");
    assert!(claimed > MAX_GOSSIP_SIZE);  // guard correctly rejects malicious input
}

The full unit-test file is available in the submission package at poc/tests/snappy_bomb.rs. To run all tests:

Bash
cd poc/
cargo test --release --test snappy_bomb -- --nocapture

Why this is sufficient under the program's PoC rules

The program rules state that for Audit Competitions, "you are only required to provide step-by-step explanations". Steps 1–6 above are the complete walkthrough from attacker action to per-node impact. The included Rust unit test exceeds the minimum requirement and verifies the underlying snappy-crate behavior the production code depends on.

No execution against project assets (mainnet, Sepolia, deployed Base infrastructure) is performed or required to demonstrate the issue.

The original report as published on Immunefi, by imbanytui. 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

The decoder trusts the attacker-controlled decompressed-length header and allocates a buffer of that size before validating it against a sane maximum.

Impact

A single small message could force a multi-gigabyte allocation per node, and on Windows, macOS or Linux with overcommit disabled the process may terminate, so an attacker could degrade or shut down a portion of nodes without flooding.

What the attacker needed

Ability to join the P2P gossip network; no authentication required; target node uses affected release

The fix

The decoder should read the claimed length cheaply and reject it if it exceeds a sane maximum before allocating, as the Go reference implementation does.

How it was found

  1. Craft a minimal snappy frame whose header claims a very large decompressed length.
  2. Publish it to one of the block gossip topics, which passes the compressed-size limit.
  3. The receiving node's block handler dispatches the message to the matching decode function.
  4. The decode function calls decompress_vec, which allocates the claimed size before reading the body.
  5. The allocation request hits the OS allocator, causing resource growth or process termination depending on platform.
  6. Repeat against multiple connected peers to affect a share of the validator population.

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.

Nodes in this network talk to each other over a peer-to-peer network and exchange compressed messages. The compression format starts with a small number that says how big the message will be after unpacking, and the code trusted that number and reserved memory for it before checking anything. A malicious peer could claim a huge size in a five-byte message, making the node try to reserve gigabytes of memory and possibly crash.

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