Skip to content

Unbounded fetch can OOM the host #264

@lthibault

Description

@lthibault

Problem

cache.fetch() returns Vec<u8> with no size cap. A guest requesting a multi-GB CID will load the entire content into host memory before writing to staging.

The ARC budget limits what stays pinned, but fetch() bypasses it — it calls pinner.fetch() directly.

Fix

Check the CID size (already known from the prior ensure() call) against a configurable maximum before fetching. Or better: stream content directly to disk instead of buffering in memory.

Context

Found by adversarial review on #263. The open_ipfs flow is:

  1. cache.ensure(cid) — pins, stores size in ARC
  2. cache.fetch(cid) — loads entire content into Vec<u8>
  3. std::fs::write(&file_path, &bytes) — writes to staging

Step 2 is the problem. A streaming approach would pipe bytes from the IPFS node directly to a file on disk.

Severity

High — a malicious or careless guest can crash the host process.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High — fix before next milestonebugSomething isn't workingtrack:ipfs-cacheIPFS cache + filesystem interceptor track

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions