Skip to content

fix: harden CAR streaming and truncation - #11409

Merged
lidel merged 3 commits into
masterfrom
harden-block-decoding
Jul 27, 2026
Merged

fix: harden CAR streaming and truncation#11409
lidel merged 3 commits into
masterfrom
harden-block-decoding

Conversation

@lidel

@lidel lidel commented Jul 27, 2026

Copy link
Copy Markdown
Member

Problem

A CAR response that stopped partway through looked exactly like a complete one. By the time anything goes wrong the status line and headers are long gone, and X-Stream-Error is set once the body is already streaming, so it rarely reaches the client and never survives a reverse proxy or CDN. Debugging a short response meant guessing which hop dropped it. Nothing bounded how deep a CAR walk goes either, and ls, dag get and dag export each hand their work to a goroutine and read the result back over a channel, where a panic ends the daemon rather than the command.

Fix

  • A CAR that stops early now ends with a marker, so a reader errors instead of accepting a short DAG as complete.
  • CAR traversal is bounded by depth, 1024 by default and configurable in boxo.
  • The three commands recover on their own goroutines and report through the channel they already use.

Dependency updates carry the rest: ipfs/boxo#1197, ipfs/go-ipld-git#77 and ipfs/go-unixfsnode#100. All three are pinned to their branches, so this needs their tagged releases before it can merge.

lidel added 2 commits July 27, 2026 01:47
ls, dag get and dag export each hand their work to a goroutine and read
the result back over a channel or pipe. Decoding and encoding there runs
whatever codec a block's CID names, so it runs third-party code, and a
panic on a detached goroutine ends the daemon rather than the command.

Each now recovers, logs, and reports through the channel it already
uses. In dag export the recover is registered after the existing cleanup
defer so it runs first, while errCh is still open.
Picks up the CAR streaming and object parsing work from ipfs/boxo#1197,
ipfs/go-ipld-git#77 and ipfs/go-unixfsnode#100. All three are pinned to
their branches for now; swap for the tagged releases before merging.
@lidel lidel added the skip/changelog This change does NOT require a changelog entry label Jul 27, 2026
@socket-security

socket-security Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedgithub.com/​ipfs/​go-ipld-git@​v0.1.2 ⏵ v0.1.3100 +1100100100100

View full report

@lidel lidel mentioned this pull request Jul 27, 2026
52 tasks
@lidel
lidel marked this pull request as ready for review July 27, 2026 00:19
@lidel
lidel requested a review from a team as a code owner July 27, 2026 00:19
@lidel
lidel requested a review from gammazero July 27, 2026 00:19
@lidel
lidel force-pushed the harden-block-decoding branch 2 times, most recently from f16762e to 86730de Compare July 27, 2026 13:57
go-ipld-git and go-unixfsnode are on their tagged releases. boxo is
pinned to main, which carries ipfs/boxo#1197 but has not been released
yet, so this still needs a boxo release before it can merge.

Notes the CAR truncation marker in the v0.43 changelog, since that is
the user-visible part of the boxo update.

Also stops a slow Ubuntu mirror from failing the ipfs-webui job. That
job installed Playwright OS dependencies for every browser although it
declares no projects and so only ever runs chromium, and the install had
no timeout of its own. When the mirror served 10.7 MB of package indices
at 39 kB/s, apt-get update alone outlasted the job's 20 minute budget and
the run was cancelled before any test started. The install is now scoped
to chromium, capped, and best effort: the runner image already ships what
headless chromium needs, and a library that really is missing surfaces
when the browser fails to launch.
@lidel
lidel force-pushed the harden-block-decoding branch from 86730de to 0ab73ab Compare July 27, 2026 14:17
@lidel
lidel merged commit f9baf8f into master Jul 27, 2026
24 checks passed
@lidel
lidel deleted the harden-block-decoding branch July 27, 2026 14:44
lidel added a commit that referenced this pull request Jul 27, 2026
* fix: recover from panics in detached goroutines

ls, dag get and dag export each hand their work to a goroutine and read
the result back over a channel or pipe. Decoding and encoding there runs
whatever codec a block's CID names, so it runs third-party code, and a
panic on a detached goroutine ends the daemon rather than the command.

Each now recovers, logs, and reports through the channel it already
uses. In dag export the recover is registered after the existing cleanup
defer so it runs first, while errCh is still open.

* chore: update boxo, go-ipld-git and go-unixfsnode

Picks up the CAR streaming and object parsing work from ipfs/boxo#1197,
ipfs/go-ipld-git#77 and ipfs/go-unixfsnode#100. All three are pinned to
their branches for now; swap for the tagged releases before merging.

* chore: update boxo, go-ipld-git and go-unixfsnode

go-ipld-git and go-unixfsnode are on their tagged releases. boxo is
pinned to main, which carries ipfs/boxo#1197 but has not been released
yet, so this still needs a boxo release before it can merge.

Notes the CAR truncation marker in the v0.43 changelog, since that is
the user-visible part of the boxo update.

Also stops a slow Ubuntu mirror from failing the ipfs-webui job. That
job installed Playwright OS dependencies for every browser although it
declares no projects and so only ever runs chromium, and the install had
no timeout of its own. When the mirror served 10.7 MB of package indices
at 39 kB/s, apt-get update alone outlasted the job's 20 minute budget and
the run was cancelled before any test started. The install is now scoped
to chromium, capped, and best effort: the runner image already ships what
headless chromium needs, and a library that really is missing surfaces
when the browser fails to launch.

(cherry picked from commit f9baf8f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip/changelog This change does NOT require a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants