Skip to content

node: buyer-side pull buffers up to server-claimed total_bytes with no blob-size ceiling (asymmetric with serving-side BlobTooLarge gate) #840

Closed

Description

@thiras

Surfaced by a full-repository review (2026-06-09).

Finding

The node-to-node pull in stream_fetch (crates/node/src/client_requester.rs:208-267) accumulates up to expected = total_bytes − byte_offset bytes into a BytesMut with no independent ceiling. total_bytes is fully server-controlled, and StreamResponse::validate() (crates/protocol/src/client.rs:362) does not bound it — it checks rate/signature/ok-consistency only. The loop's cumulative > expected guard caps growth at the server's promise, not at a sane maximum, and the allocation happens before any hash check.

The serving side already enforces the inverse gate (BlobTooLarge at client.rs:519); the buying side does not.

Impact

A malicious or buggy selected upstream provider can drive the buying node toward OOM with one oversized total_bytes claim. Partly self-limiting (the buyer pays vouchers per interval and selected the provider), but a single oversized response allocates before payment or hash verification bounds it.

Fix

Thread the node's max_blob_size_bytes (already plumbed into ClientHandler) into stream_fetch and reject total_bytes above it before entering the receive loop, mirroring the serving-side gate.

Refs

Activity

  1. added
    kind:bug
    kind:security
    prio:medium
    on Jun 9, 2026
  2. github-actions commented on Jun 9, 2026

    @github-actions

    🎯 Triage report

    Asymmetric blob-size enforcement in the node-to-node pull path: the serving side already gates on BlobTooLarge (crates/protocol/src/client.rs:519), but the buying side (stream_fetch in client_requester.rs:208-267) allocates a BytesMut sized to the server's claimed total_bytes before any hash check. A malicious or misconfigured upstream can claim an arbitrarily large total_bytes and drive the buying node toward OOM. The fix is well-specified: thread max_blob_size_bytes (already available in ClientHandler) into stream_fetch and reject oversized claims before entering the receive loop.

    📊 Assessment

    Dimension Value Reasoning
    Type Bug Security vulnerability in a core network path — missing input validation on an untrusted server-supplied field
    Labels rust added; bug, security, medium retained Rust implementation fix; existing priority/classification labels are appropriate — "medium" is reasonable given partial self-limiting (buyer selects provider, pays per interval)
    Coding agent Suitable Clear location (client_requester.rs:stream_fetch), well-defined fix with an existing mirror pattern on the serving side, regression test anchor in #746

    🔗 Similar issues

    💡 Notes and suggestions

    Root cause location:

    • crates/node/src/client_requester.rs:208-267 — stream_fetch receive loop; expected = total_bytes − byte_offset drives BytesMut growth
    • crates/protocol/src/client.rs:362 — StreamResponse::validate() checks rate/signature/ok-consistency only; does not bound total_bytes
    • crates/protocol/src/client.rs:519 — serving-side BlobTooLarge gate to mirror

    Suggested fix checklist:

    • Add max_blob_size_bytes: u64 parameter to stream_fetch (or resolve it from context already available in ClientHandler)
    • Before the receive loop, check if total_bytes - byte_offset > max_blob_size_bytes { return Err(...) } — reject early, no allocation
    • Optionally: move the bound check into StreamResponse::validate() if max_blob_size_bytes can be passed there, to keep validation centralised
    • Add a regression test under #746's integration test scaffolding: a mock upstream that returns an oversized total_bytes claim should be rejected with a protocol error, not an OOM

    Severity context:
    The "partly self-limiting" note in the issue is valid — the buyer has to actively select this provider and open a payment channel before the oversized response can be returned. However, the allocation precedes hash verification and payment settlement, so a rogue/buggy node in the provider table can still exploit the window. The medium label is appropriate; if PoC deployment is on shared infrastructure, maintainers may want to reconsider poc-blocking.

    Generated by Agentic Triage for issue #840 · sonnet46 508K · ◷

    Add this agentic workflows to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/issue-triage.md@94ec5db57374c5b04a4b8eef8b4413f9af44d63f
    
  3. added
    rust
    on Jun 9, 2026
  4. self-assigned this
    on Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind:bugkind:securityprio:mediumrust

Type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions