Skip to content

fix(zip): validate Zstandard members through frame completion - #12461

Merged
morluto merged 1 commit into
cursor/zstd-exact-frame-bfbafrom
audit/zip-zstandard-frame-completion
Nov 19, 2026
Merged

morluto merged 1 commit into
cursor/zstd-exact-frame-bfbafrom
audit/zip-zstandard-frame-completion

Conversation

@morluto

@morluto morluto commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Summary

ZIP method 93 now validates the full compressed member through the shared Zstandard wire reader. It ends a decoder write at each complete frame boundary so Node 22 can read valid concatenated frames, including skippable frames. The stream refuses incomplete framing at EOF. ZIP still owns the decoded size and CRC, and extraction still publishes only after the stream and cleanup complete.

Related to #12447. Stacked on #12416 because the buffered and streaming paths share one frame grammar.

Validation

The baseline resolved cleanly when a complete text frame was followed by incomplete final framing on Node 24. The fixed reader refuses that case. Each supported Node floor (22.23.4, 24.22.1, and 26.12.1) passed all 66 focused ZIP and codec tests. The 30 compiled ZIP integrity tests passed, including cleanup of unpublished extraction output after a late format refusal. check:fast and diff checks passed. The candidate merges cleanly into the current base.

Zstandard frame format

Author readiness

Human owner: @morluto

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

@morluto
morluto marked this pull request as ready for review November 19, 2026 17:58
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T18:00:05.632044Z b1af6db Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[High impact] The PR appears safe to merge based on the code reviewed.

Summary

ZIP Zstandard reads now check that every compressed frame finishes before reporting success. Buffered and streaming readers share the same frame grammar.

  • ZIP Zstandard members are checked through complete frame boundaries.

No actionable issues found. No superseding PR appears in the supplied stack. Diff whitespace checks passed; tests were not run because dependencies are not installed.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[ZIP compressed member] --> B[Shared frame reader]
  B --> C[Writes split at frame boundaries]
  C --> D[Native Zstandard decoder]
  D --> E[ZIP size and CRC checks]
  E --> F[Producer success and source check]
  F --> G[Report EOF]
  B -->|Incomplete frame| H[Fail read and discard extraction]
Loading

Reviews (1) · Last reviewed commit: "fix(zip): require complete Zstandard mem..." · Reviewed by Greptile

@morluto
morluto merged commit 8309cb5 into cursor/zstd-exact-frame-bfba Nov 19, 2026
1 check passed
@morluto
morluto deleted the audit/zip-zstandard-frame-completion branch November 19, 2026 18:02
morluto added a commit that referenced this pull request Nov 19, 2026
…12416)

* fix(zstd): share exact-frame Zstandard decoding across ELF and OTA

Walk RFC 8878 frames once so ELF sections, Android OTA REPLACE_ZSTD, and GPU payloads reject truncated headers, blocks, checksums, and trailing bytes on every supported Node runtime. Bound that walk with the runtime zstd.max_frames setting.

* fix(zstd): keep frame output tight and report GPU frame-cap refusals

Copy each Node 22 frame off its decoder chunk before the next frame is decoded. Map a GPU zstd.max_frames refusal through the resource-limit contract instead of a provider failure.

Co-authored-by: morluto <[email protected]>

* fix(zstd): keep frame-cap refusals and bad seeds out of malformed results

Project zstd.max_frames through one resource-limit helper for ELF notes, DWARF, GPU, and artifact reads. An invalid REA_ZSTD_MAX_FRAMES seed stays a configuration failure, and frame-header tests cover content size, window, dictionary id, and RLE blocks.

Co-authored-by: morluto <[email protected]>

* fix(zstd): yield GPU frame decoding so cancellation can land

The frame-by-frame fallback awaits a caller pause before each data frame. GPU yields and checks the read signal there, so a many-frame payload does not finish before a disconnect is observed.

Co-authored-by: morluto <[email protected]>

* fix(zstd): advertise the frame cap and keep strict GPU decode cancellable

List every operation that enforces zstd.max_frames, including GPU, DWARF, and ELF notes. The strict sequence uses the async decoder and checks the caller signal again after it returns, and a single output buffer is not copied a second time.

Co-authored-by: morluto <[email protected]>

* fix(zstd): refresh analysis-setting schemas and GPU frame-cap projection

Regenerate the advertised input summaries for inspect_analysis_settings and update_analysis_settings. GPU inventory now throws the projected zstd.max_frames resource limit from payload decode and #retainFailure, so the adjustable setting survives the public failure.

Co-authored-by: morluto <[email protected]>

* style(gpu): format the frame-cap projection throw

oxfmt keeps the zstd.max_frames throw in #retainFailure on one line so CI format:check matches the local formatter.

Co-authored-by: morluto <[email protected]>

* fix(zstd): yield after the last frame-by-frame GPU decode

The fallback returned success in the same turn as the final synchronous frame, so a queued abort was still invisible to the caller's signal check. Pause once more before that success, matching the strict sequence.

Co-authored-by: morluto <[email protected]>

* fix(zstd): yield ELF, OTA, and DWARF frame decoding on the caller signal

The synchronous frame loop ignored abort signals owned by inspect_elf_notes, inspect_dwarf_units, and Android OTA partition reads. Those callers now use the cooperative decoder and yield before Zstandard work, and 32-frame cancellations cover each path.

Co-authored-by: morluto <[email protected]>

* fix(zstd): observe cancellation during structural parsing

* fix(zstd): project section-name frame caps at the ELF directory boundary

readElfDirectoryFromBuffer now requires the caller's operation and throws the adjustable zstd.max_frames resource limit. Hardening, unwind, and the other directory consumers keep that typed refusal instead of an adapter or I/O error.

Co-authored-by: morluto <[email protected]>

* fix(zstd): preserve optional ELF evidence when frames are capped

* fix(zip): validate Zstandard members through frame completion (#12461)

fix(zip): require complete Zstandard member frames

* fix(elf): yield hardening section name decoding

* fix(elf): yield section names for unwind and export reads

* fix(zstd): yield ELF directory reads that already own a cancellation signal

Hardening, unwind, initializers, exports, kernel modules, debug link, and Android JNI now read section names through the cooperative directory when their caller has a signal. Readers with no signal stay synchronous.

Co-authored-by: morluto <[email protected]>

* fix(elf): share one initializer directory and retain its snapshot

* fix(android): reuse the admitted JNI ELF directory

* fix(elf): retain optional debug candidate evidence through cooperative decoding

* fix(zstd): yield ELF section names for Go, Rust, and IL2CPP

These inspections already own an abort signal. Their ELF directory read now uses the cooperative container decoder so a queued cancellation can land during a many-frame section-name table.

Co-authored-by: morluto <[email protected]>

* fix(elf): recognize compressed kernel modules before ELF decoding

The cooperative module reader decoded the bytes as ELF before the container check, so gzip, xz, and zstd modules became malformed images. The compression check now returns the unsupported-container report first.

Co-authored-by: morluto <[email protected]>

* refactor(elf): classify each container once before reading it

* fix(il2cpp): preserve admission order during cooperative linking

* fix(elf): reuse section-name decoding in debug-link comparison (#12472)

* style(elf): format updated section-reader test calls

---------

Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: morluto <[email protected]>
@morluto morluto added bug Something isn't working area: evidence Evidence, artifacts, and reconstruction labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: evidence Evidence, artifacts, and reconstruction bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant