Repository navigation
feat(extract): read remote APFS files through HTTP ranges - #1409
Merged
blacktop merged 9 commits intoNov 17, 2026
Merged
Conversation
Write and WriteRoot share one temp-file, sync and rename sequence. Write keeps operating on plain paths; WriteRoot runs the same steps confined to an os.Root the caller already holds. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Reader authenticates the root header and cluster header chain, then decrypts only the segments a ReadAt touches, with a bounded plaintext cache. The prologue parser, root validation and cluster walk are factored out of decrypt (readPrologue, validateRoot, walkSegments) and shared by both paths. ReadMetadata reads AEA metadata from an io.ReaderAt, and Metadata.SymmetricKey resolves an embedded or FCS-wrapped key. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
An io.ReaderAt for sparse remote access: 64 KiB pages in an 8 MiB LRU, large reads sent as direct ranges of up to 4 MiB. Every response must be a 206 whose Content-Range, length and ETag match the request; a full-body 200 is rejected unread. Transport failures and 5xx, 429 and 408 responses are retried twice. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
ipsw extract --remote --files --ranged fetches matching files from an APFS image inside a remote IPSW without downloading or mounting the image. --ranged-dmg selects fs (default), sys, app or exc. The stored ZIP member is read through download.RangeReader, unwrapped through aea.Reader, UDIF and GPT when present, and walked with go-apfs OpenReader. Anchored patterns prune directories that cannot match. Extracted files keep the image's permission bits. Unsupported layouts are errors; there is no fallback to a full download. go-apfs is pinned to the head of blacktop/go-apfs#89, which adds OpenReader, until that merges. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
KishanBagaria
marked this pull request as ready for review
November 16, 2026 08:30
FuzzNewReader feeds arbitrary archives to the prologue parser. FuzzWalkSegments authenticates a cluster header built from the fuzz input, so the segment bounds checks are exercised rather than stopped at the HMAC. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
FuzzAPFSPartition checks that a partition returned for an arbitrary image lies inside it. FuzzPrefixMatcher checks that pruning never skips a directory above a path the pattern matches. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
v1.0.31 includes OpenReader (blacktop/go-apfs#89). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
| if err != nil { | ||
| return nil, fmt.Errorf("ranged APFS %s: %w", name, err) | ||
| } | ||
| if err := os.MkdirAll(destination, 0755); err != nil { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
ipsw extract --remote --files --ranged, which fetches matching files from an APFS image inside a remote IPSW using HTTP byte ranges, without downloading or mounting the image.--ranged-dmgselectsfs(default),sys,apporexc.Example: 70 loctables from the 25.6 GB macOS 27.2.1 (26B131) restore image cost 57.6 MB in 238 range requests and about 9 seconds. Also discussed in #1375 where reporter wanted one
Info.plistacross many OS versions.Builds on #1408 (merged) and uses go-apfs v1.0.31, which includes the
OpenReaderAPI from blacktop/go-apfs#89.masteris merged in, so the diff is only this PR's changes.How it works: the stored ZIP member is read through
download.RangeReader, unwrapped throughaea.Reader, UDIF and GPT when present, and walked with go-apfsOpenReader. Patterns that must match from the start of the path prune directories that cannot match.Scope and limits:
--flatand--lookupare rejected.Testing
go test ./...withmastermerged in and go-apfs v1.0.31: everything passes exceptpkg/car/internal/render,pkg/lzmaandpkg/usb/{afc,apps,debugserver,forward}, which fail identically on unmodifiedmasteron this machine.New tests: an end-to-end synthetic IPSW (plain and AEA) served over HTTP, including permission bits and a pre-existing output symlink; deflated-member rejection; GPT partition selection; prefix pruning; CLI flag validation.
Fuzz tests:
FuzzAPFSPartition(a partition returned for an arbitrary image must lie inside it) andFuzzPrefixMatcher(pruning must never skip a directory above a path the pattern matches). Ran about 40 s and 60 s (1.2 million and 1.1 million executions) with no failures.Live run on macOS 27.2.1 (26B131):
Exit 0, 70 files, each byte-identical (
cmp) to the same path on the installed 26B131 system.Ranged 141-12228-174.dmg.aea: 238 requests, 57608766 bytes downloaded (IPSW: 25595954706 bytes).A second live run extracted
/usr/libexec/amfidand/usr/libexec/locationd: both mode 755 and byte-identical to the installed copies.Not run:
make fmtin full (gofmtis clean on the changed files) andmake docs(the two new flags were added towww/docs/cli/ipsw/extract.mdby hand).AI Assistance
Planned and written by GPT 6.1 Sol + Claude Fable 5.2. Reviewed manually.