Skip to content

node: cache-miss pull-through pays upstream for the entire blob before collecting any downstream voucher #856

Closed

Description

@thiras

Severity: MEDIUM — from the 2026-06-10 full-repository review (#834 surface).

Location

  • crates/node/src/handlers/client.rs:584-594 — triggers try_pull_through → cache.populate(hash) (client.rs:297-298)
  • The populate runs the full NodeOrigin discover→pull and pays the upstream for the whole blob (stream_fetch buffers and pays to completion) before deliver collects the first downstream voucher (client.rs:680)

Scenario

An authorized client (one that proves channel ownership, satisfying pull_authorized) with a near-empty deposit — or one that simply drops the stream right after the fill — makes the node front the full upstream USDC cost while paying back at most one voucher interval (or zero). The node's loss per request is bounded only by max_blob_size_bytes, not by anything the client has at stake. Repeatable across hashes the client knows aren't cached.

Not a duplicate

#848 is an unknown/absent channel (free first interval); here the channel is known and owned — the distinct defect is the prepay-whole-blob-then-recover-incrementally timing asymmetry. #821 is opting out of relaying unclaimed content; #840 is buyer-side memory buffering.

Fix direction

Gate the pull on the owning channel having remaining deposit ≥ the (probed) blob cost, and/or stream-and-forward so downstream voucher collection paces the upstream spend rather than paying it all up front.

Activity

  1. added
    kind:security
    design:economics
    prio:medium
    rust
    on Jun 10, 2026
  2. added
    kind:bug
    on Jun 10, 2026
  3. github-actions commented on Jun 10, 2026

    @github-actions

    🎯 Triage report

    Confirmed economic/security vulnerability in the cache-miss pull-through path: a verified channel owner with minimal deposit (or intent to drop the stream) can force the node to fully pre-pay the upstream blob cost via stream_fetch before collecting even one downstream voucher. The node's exposure per request is bounded only by max_blob_size_bytes and the attack is repeatable across any hashes the client knows are uncached. Issue precisely identifies the code locations (client.rs:584-594, :297-298, :680) and two remediation directions.

    📊 Assessment

    Dimension Value Reasoning
    Type Bug Exploitable timing asymmetry in payment flow — node fronts full upstream USDC cost before any downstream revenue
    Labels bug, technical (added) Existing security/economics/medium/rust labels accurate; bug for defect classification, technical for implementation scope
    Coding agent Needs more info Code locus is precise, but two distinct remediation paths (deposit pre-check vs. stream-and-forward) require a design decision before implementation begins

    🔗 Similar issues

    💡 Notes and suggestions

    Root cause: client.rs:297-298 calls cache.populate(hash) synchronously (full blob, paid to completion) before the downstream deliver at :680 collects the first voucher. pull_authorized validates channel ownership and existence but does not verify whether the channel's remaining deposit covers the blob cost.

    Two remediation paths — pick one:

    1. Pre-flight deposit check (faster, partial mitigation): Before try_pull_through, query the channel's remaining deposit and compare against max_blob_size_bytes as a conservative ceiling (exact size unknown pre-fetch). Reject with InsufficientDeposit if deposit < ceiling. Simple guard; does not close the window for legitimate clients whose deposit is large enough but who drop mid-stream — that's a separate leech-ratio concern.

    2. Stream-and-forward pacing (full fix, larger refactor): Restructure try_pull_through → populate so upstream payment is interleaved with downstream voucher collection — the node only advances the upstream pull after receiving a downstream voucher for the prior interval. Eliminates the timing gap entirely but requires the cache engine to expose a chunk-streaming API rather than buffer-to-completion.

    Suggested sub-tasks:

    Interaction with #848: Fixing #848 (reject unknown channel before streaming) does not affect this issue — the channel here is known and valid. The two fixes are complementary; closing both is needed to fully harden the payment flow.

    Generated by Agentic Triage for issue #856 · sonnet46 646.7K · ◷

    Add this agentic workflows to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/issue-triage.md@94ec5db57374c5b04a4b8eef8b4413f9af44d63f
    
  4. self-assigned this
    on Jun 13, 2026
  5. thiras commented on Jun 13, 2026

    @thiras
    ContributorAuthor

    Follow-ups split out of the #893 review (non-blocking, deferred from that PR):

  6. added a commit that references this issue on Jun 13, 2026
  7. added a commit that references this issue on Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

design:economicskind: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