Skip to content

cache: streaming-path captured-error partial import is never logically evicted — wrong-hash bytes serveable until next GC sweep #835

Closed

Description

@thiras

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

Finding

When count_and_cap_stream captures a mid-stream error (a BlobTooLargeMarker cap breach or a transient I/O error), iroh-blobs::add_stream still commits the partial bytes under their own BLAKE3 hash. The captured-error branch in pull_through_attempt (crates/cache/src/engine.rs:1676-1697) only drops the temp tag and returns the error — unlike the clean-stream HashMismatch branch (engine.rs:1716-1746) and the drain branch (engine.rs:1807-1820), it never calls self.evict(actual).

Impact

The partial content is a deterministic prefix of attacker-controlled bytes, so an adversarial origin knows the partial-content hash and can request it: engine.has(partial_hash) / engine.get(partial_hash) will serve those bytes until the iroh-blobs GC sweep runs (default gc_interval_sec = 300), and indefinitely if an operator sets gc_interval_sec = 0 (a supported config). This is a cache-poisoning window, not just a disk leak.

The existing test gc_reclaims_cap_breach_partial_bytes (crates/cache/tests/pull_through.rs:315) only asserts GC reclaims the disk; it never asserts !engine.has(partial_hash), so the serving window is untested.

Fix

In the captured-error arm, compute the committed partial hash from the temp tag before dropping it and call self.evict(partial_hash), exactly as the HashMismatch arm does — blocking serving immediately regardless of GC cadence. Add a !engine.has(partial_hash) assertion to the existing test.

Broader cleanup: the three wrong-hash commit/cleanup paths (streaming-mismatch, streaming-captured-error, drain-mismatch) have drifted; unifying them behind one "reject + logical-evict + make-GC-eligible" helper would close this and the drain-path leak (filed separately) together.

Refs

Activity

  1. added
    kind:bug
    kind:security
    prio:high
    on Jun 9, 2026
  2. added
    rust
    kind:test
    on Jun 9, 2026
  3. github-actions commented on Jun 9, 2026

    @github-actions

    🎯 Triage report

    Security bug in crates/cache/src/engine.rs: the captured-error arm of pull_through_attempt (lines 1676–1697) drops the temp tag without calling self.evict(partial_hash), so iroh-blobs retains the partial bytes as serveable. Because partial bytes are a deterministic prefix of origin-controlled data, an adversarial origin can precompute the BLAKE3 prefix hash and fetch it directly — bypassing content-addressing integrity until the next GC sweep, or indefinitely if gc_interval_sec = 0. This is a cache-poisoning gap distinct from the disk-leak closed by #518.

    📊 Assessment

    Dimension Value Reasoning
    Type Bug Incorrect program behaviour with a security impact; not a missing feature
    Labels bug, security, high, rust, testing, poc-blocking added Active cache-poisoning surface in the CDN serving path; must be closed before PoC network deployment
    Coding agent Suitable Fix is precisely specified: one code path, exact file/line references, a model arm (HashMismatch, 1716–1746) to follow, and a concrete test assertion to add

    🔗 Similar issues

    💡 Notes and suggestions

    Fix checklist:

    • In the captured-error arm (engine.rs:1676–1697): read the committed partial hash from the TempTag before dropping it, then call self.evict(partial_hash) — identical pattern to the HashMismatch arm at 1716–1746.
    • In crates/cache/tests/pull_through.rs:315 (gc_reclaims_cap_breach_partial_bytes): add assert!(!engine.has(partial_hash)) immediately after the cap-breach error, before the GC assertion — this tests the logical eviction, not just disk reclaim.
    • Optional but high-value: unify the three wrong-hash cleanup paths (streaming-mismatch, streaming-captured-error, drain-mismatch) behind a single reject_partial(hash) helper that calls evict + makes GC-eligible. This would also close the drain-path leak filed separately.

    Key notes for the coding agent:

    • The partial hash must be extracted from TempTag before the tag is dropped; dropping it first makes the hash unavailable.
    • The HashMismatch arm (engine.rs:1716–1746) is the canonical pattern — the captured-error arm should mirror it exactly for this step.
    • Transient I/O errors and BlobTooLargeMarker cap breaches both flow through the captured-error arm; both need the eviction.
    • When gc_interval_sec = 0 (a supported config), the serving window is permanent without this fix — no GC rescue is possible.

    Generated by Agentic Triage for issue #835 · sonnet46 723.6K · ◷

    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 10, 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:securitykind:testprio:highrust

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions