Skip to content

cache: wire iroh-blobs GC into runtime — partial-import bytes (hash-mismatch, mid-stream cap breach) currently leak disk indefinitely #518

Closed

Description

@thiras

Problem

After #271 landed (streaming origin pull-through), the cache engine commits a partial blob to iroh-blobs whenever the origin stream errors mid-flight (cap breach, idle timeout, decoder failure) or when the upstream returns bytes whose BLAKE3 doesn't match the requested hash. The pull_through path drops the resulting TempTag without promoting it to a named tag, so iroh-blobs treats the bytes as unprotected and GC-eligible — but the deCDN node does not currently run iroh-blobs GC.

Verified: zero invocations of iroh_blobs::store::gc::run_gc / gc_run_once / equivalent in crates/cache or crates/node (grep -r 'gc_' crates/). Until GC is wired into the runtime, every mid-stream failure strands disk bytes for the lifetime of the process — and likely across restarts (FsStore persists).

Threat model

A hostile origin can amplify disk usage:

  • Stream max_blob_size_mb - 1 of garbage, then close the connection / send a body cap breach. The bytes are committed under whatever hash they accidentally produce, dropped from TempTag, and sit on disk.
  • Repeat. Each iteration adds ~max_blob_size_mb of garbage to the blob store. Default cap is 1 GB; a few thousand requests fill the disk.

Cache-poisoning component is mitigated at the engine layer (#271 PR4 added `self.evict(actual)` on hash mismatch so `engine.has(actual)` returns false), but the bytes still occupy disk and `Blobs::has(actual)` would return true to any direct iroh-blobs consumer.

Acceptance

  • iroh-blobs GC runs on a scheduled interval (configurable, default e.g. 5 min) inside the `decdn-node` runtime.
  • Manual `decdn admin cache gc` admin RPC for on-demand reclamation.
  • Test: stream a known-bad-hash response, assert `Blobs::has(actual_hash)` becomes false within one GC interval.
  • Operator-facing metric: `gc_runs_total`, `gc_bytes_reclaimed_total`.

Related

Metadata

Metadata

Assignees

Labels

kind:bugkind:securityprio:high

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions