Skip to content

cache: hash-mismatch handler permanently evicts the *actual* hash — a malicious upstream can durably censor any blob it holds the bytes of #853

Closed

Description

@thiras

Severity: HIGH — from the 2026-06-10 full-repository review.

Location

crates/cache/src/engine.rs:1807 (streaming path) and :1882 (drain path) — on a hash mismatch, the engine calls self.evict(actual).

Problem

evict(actual) adds the actual (correctly computed) hash to the logical-evicted set, which is fsync-persisted to <cache_dir>/evicted.log and is sticky for the life of the file with no unevict path — get/has/populate all return absent for it forever, surviving restart.

For content-addressed storage this is logically unsound: bytes whose BLAKE3 is actual are the authorized content for actual. The eviction provides zero poisoning protection (the requested hash H is correctly never committed) but inflicts a permanent denial on actual.

Attack

With the node-to-node Peer origin (#831/#834), a malicious upstream answers any cache-miss pull routed to it with the bytes of a victim blob A it possesses. The victim requested H, computes actual = A != H, and permanently blacklists A. The attacker censors any blob it holds the preimage of, on any node that pulls through it — cheaply and durably.

Secondary impact: each event grows evicted.log and burns the in-memory cap toward MAX_EVICTED_ENTRIES (after which legitimate DMCA evicts fail with EvictionLimitExceeded), plus a blocking sync_all per event (the latter already noted in #845/#837).

Not a duplicate

#837/#835 cover the wrong-hash bytes (GC-unreclaimable disk growth / transient serveability). This is the inverse: evict(actual) durably censors the legitimate hash itself — a serve-denial vector.

Fix direction

Drop the evict(actual) call entirely (content-addressing already makes serving actual's bytes for actual correct), or scope the cleanup to dropping the temp/named tag for the partial without touching the persisted evicted set. At minimum, never persist mismatch-derived hashes to evicted.log.

Activity

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

    @github-actions

    🎯 Triage report

    A HIGH-severity logic inversion in the hash-mismatch cleanup path: when received bytes don't match the requested hash H, the engine calls evict(actual) — permanently blacklisting the correct hash for actual's own bytes. With the peer-origin pull path live (#831/#834), a malicious upstream can durably censor any blob it holds by feeding its bytes as a wrong-hash response, causing the victim node to evict the victim blob forever. The fix direction is clear and well-scoped: stop calling evict(actual) on mismatch, only clean up the partial for GC eligibility.

    📊 Assessment

    Dimension Value Reasoning
    Type Bug Security defect in existing implementation
    Labels poc-blocking added; bug, security, high, rust already present Peer-origin pull path (#831/#834) is PoC-scope and this is a direct attack vector against it
    Coding agent Suitable Two-line call-site fix with a clear semantic: drop evict(actual) at engine.rs:1807 and :1882; replace with tag/GC cleanup only. No design decisions required.

    🔗 Similar issues

    💡 Notes and suggestions

    Root cause in one line: evict(H) would be the correct defensive call (never commit mismatched content under the requested hash), but the code calls evict(actual) — blacklisting legitimate content for a hash the node just verified is correct.

    Precise fix locations:

    • engine.rs:1807 — streaming path HashMismatch arm: remove self.evict(actual);
    • engine.rs:1882 — drain path mismatch arm: remove self.evict(actual);

    In both cases the right action is:

    1. Do NOT commit the bytes under H (already correct — this is the H != actual guard).
    2. Drop the temp-tag / named-tag to make the bytes GC-eligible (see cache: drain-path hash mismatch leaves a persistent named tag — wrong-hash bytes are GC-unreclaimable (unbounded disk growth) #837 for the drain path gap here).
    3. Do NOT touch evicted.log with actual — actual is valid, legitimate content.

    Recommended implementation approach:
    Introduce a unified reject_mismatch(partial_tag_or_handle) helper that handles GC eligibility (drop tag) without touching the evicted set. Call it from all three wrong-hash paths (streaming HashMismatch, streaming captured-error, drain HashMismatch) to close this issue and #837/#835 together without further drift.

    Secondary concern (from #845): evict() currently does a blocking sync_all() on the async runtime at engine.rs:878-928, :1737, :1812. Once the evict call is removed from the mismatch path, this concern remains for legitimate DMCA evicts — worth moving to spawn_blocking when touching the eviction code.

    Checklist for the fix PR:

    Generated by Agentic Triage for issue #853 · sonnet46 584.9K · ◷

    Add this agentic workflows to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/issue-triage.md@94ec5db57374c5b04a4b8eef8b4413f9af44d63f
    
  3. 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:securityprio:highrust

Type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions