You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cache: drain-path hash mismatch leaves a persistent named tag — wrong-hash bytes are GC-unreclaimable (unbounded disk growth) #837
Surfaced by a full-repository review (2026-06-09). Sibling of #835 (same root cause family: the three wrong-hash commit/cleanup paths have drifted).
Finding
commit_buffered_bytes (crates/cache/src/engine.rs:1788-1823) commits via add_bytes(bytes).await, which resolves through iroh-blobs' AddProgress::with_tag() (iroh-blobs-0.101.0/src/api/blobs.rs:664) and creates a persistent named tag. On hash mismatch the code calls self.evict(actual) (correctly stops serving) but never deletes that named tag — so unlike the streaming path's drop(temp_tag), the bytes stay GC-protected forever.
Impact
A hostile origin returning small (≤ buffered_max_bytes, default 4 MiB) mismatched bodies on repeated requests grows on-disk usage without bound. The gc_bytes_reclaimed/pull_through_bytes amplification alert will not fire, because GC genuinely cannot reclaim these bytes.
Fix
On the drain-path mismatch, delete the named tag (tags API) alongside the logical evict so the bytes become GC-eligible, matching the streaming path's temp-tag-drop semantics. Preferably as part of a unified "reject + logical-evict + make-GC-eligible" helper shared by all three wrong-hash paths (see #835).
Related LOW noted in the same review: evict() does a blocking sync_all() directly on the async runtime and is invoked from the mismatch hot path (engine.rs:878-928, :1737, :1812) — worth moving to spawn_blocking when touching this code.
commit_buffered_bytes (engine.rs:1788-1823) uses add_bytes().await which resolves via AddProgress::with_tag() and creates a persistent named tag in iroh-blobs. Unlike the streaming path's TempTag (dropped on scope exit), this tag is never removed on hash mismatch — only self.evict(actual) is called. Wrong-hash bytes from the drain path are therefore permanently GC-protected and accumulate on disk indefinitely. A hostile origin can exhaust node storage by repeatedly sending small (≤4 MiB default) mismatched bodies, and the standard gc_bytes_reclaimed/pull_through_bytes amplification alert will not fire because GC genuinely cannot reclaim these bytes.
📊 Assessment
Dimension
Value
Reasoning
Type
Bug
Incorrect resource lifecycle — named tag is never deleted, permanently blocking GC reclamation
Labels
security added
Hostile-origin disk-exhaustion vector; existing bug+medium are correct and unchanged
Coding agent
Suitable
Code location pinpointed (engine.rs:1788-1823), fix clearly described (delete named tag alongside evict()), success criteria explicit
Root cause detail: add_bytes(bytes).await → AddProgress::with_tag() inserts a Tag entry into iroh-blobs' tag store. Without an explicit store.tags().delete(tag) the blob is permanently GC-protected regardless of sweep cadence. The streaming path avoids this because TempTag is dropped on scope exit; the buffered path has no equivalent automatic cleanup.
Minimal fix (drain path only):
Retrieve the tag value from the add_bytes result before the mismatch check, then delete it on the mismatch branch alongside self.evict(actual):
// In commit_buffered_bytes hash-mismatch branch (~engine.rs:1812)// After: self.evict(actual).await?;// Add:self.blobs.tags().delete(committed_tag).await?;
The exact tag handle depends on the AddProgress/add_bytes API surface — capture it from the outcome before the hash comparison.
Preferred fix (unified helper, closes #835 and #837 together):
Extract a reject_and_make_gc_eligible(hash, tag) helper called from all three wrong-hash arms:
engine.rs:1716-1746 — streaming clean hash-mismatch arm
engine.rs:1807-1820 — drain hash-mismatch arm (this issue)
This is the approach the author recommends and would close the class of bugs.
Secondary (LOW) — blocking I/O inside evict(): evict() calls sync_all() synchronously at lines 878-928, 1737, and 1812; should be moved to spawn_blocking when this code is touched to avoid blocking a tokio thread-pool thread.
Suggested test additions:
Trigger drain-path with body ≤ buffered_max_bytes and a mismatched hash
Assert engine.has(actual_hash) is false immediately after (no serving window)
Assert that after a GC sweep, disk usage returns to baseline (no GC-protected orphan tag)
Monitoring note for operators: Because GC cannot reclaim these bytes, the standard amplification alert is silent. Until the fix lands, operators running high-traffic nodes with potentially hostile origins may want to monitor iroh-blobs tag-count growth as a secondary signal.
Activity
github-actions commentedon Jun 9, 2026
🎯 Triage report
commit_buffered_bytes(engine.rs:1788-1823) usesadd_bytes().awaitwhich resolves viaAddProgress::with_tag()and creates a persistent named tag in iroh-blobs. Unlike the streaming path'sTempTag(dropped on scope exit), this tag is never removed on hash mismatch — onlyself.evict(actual)is called. Wrong-hash bytes from the drain path are therefore permanently GC-protected and accumulate on disk indefinitely. A hostile origin can exhaust node storage by repeatedly sending small (≤4 MiB default) mismatched bodies, and the standardgc_bytes_reclaimed/pull_through_bytesamplification alert will not fire because GC genuinely cannot reclaim these bytes.📊 Assessment
securityaddedbug+mediumare correct and unchangedevict()), success criteria explicit🔗 Similar issues
💡 Notes and suggestions
Root cause detail:
add_bytes(bytes).await→AddProgress::with_tag()inserts aTagentry into iroh-blobs' tag store. Without an explicitstore.tags().delete(tag)the blob is permanently GC-protected regardless of sweep cadence. The streaming path avoids this becauseTempTagis dropped on scope exit; the buffered path has no equivalent automatic cleanup.Minimal fix (drain path only):
Retrieve the tag value from the
add_bytesresult before the mismatch check, then delete it on the mismatch branch alongsideself.evict(actual):The exact tag handle depends on the
AddProgress/add_bytesAPI surface — capture it from the outcome before the hash comparison.Preferred fix (unified helper, closes #835 and #837 together):
Extract a
reject_and_make_gc_eligible(hash, tag)helper called from all three wrong-hash arms:engine.rs:1676-1697— streaming captured-error arm (cache: streaming-path captured-error partial import is never logically evicted — wrong-hash bytes serveable until next GC sweep #835)engine.rs:1716-1746— streaming clean hash-mismatch armengine.rs:1807-1820— drain hash-mismatch arm (this issue)This is the approach the author recommends and would close the class of bugs.
Secondary (LOW) — blocking I/O inside
evict():evict()callssync_all()synchronously at lines 878-928, 1737, and 1812; should be moved tospawn_blockingwhen this code is touched to avoid blocking a tokio thread-pool thread.Suggested test additions:
buffered_max_bytesand a mismatched hashengine.has(actual_hash)isfalseimmediately after (no serving window)Monitoring note for operators: Because GC cannot reclaim these bytes, the standard amplification alert is silent. Until the fix lands, operators running high-traffic nodes with potentially hostile origins may want to monitor iroh-blobs tag-count growth as a secondary signal.
Add this agentic workflows to your repo
To install this agentic workflow, run
fix(cache): separate DMCA eviction from wrong-hash rejection; reclaim…