#6949

fix(pyinstaller): require NUL-padded CArchive TOC names

Draftrudycelekliwants to merge intofrom

Summary

Reject PyInstaller CArchive TOC entries whose fixed-size name field is not a NUL-padded C string. REA previously accepted two malformed shapes: a name field with no NUL terminator (the whole field became the name) and a terminated name followed by nonzero padding (the trailing bytes were silently ignored).

Problem and expected behavior

PyInstaller's bootloader declares each entry as TOC_ENTRY with char name[1] padded to a 16-byte multiple, and reads it with C string functions. Its writer, CArchiveWriter._serialize_toc, appends the terminating NUL and zero-pads the rest of the field via struct.

  • Unterminated field: the native consumer would read past the record; REA invented a logical member name from the padding bytes.
  • Terminated name with nonzero padding: no PyInstaller writer produces this; REA accepted it as a normal entry.

Both must fail with the existing table-indexed format diagnostic (CArchive table index N at TOC offset M: CArchive entry name is not NUL-padded).

Change and scope

  • tocName in src/artifacts/pyinstaller/CArchiveLayout.ts requires a NUL byte and requires every byte from the first NUL to the end of the field to be zero, before decoding the name as UTF-8.
  • Two regression tests in PyInstallerFormatBoundaries.test.ts, one per malformed shape, each built from an otherwise valid 32-byte TOC record.

No valid-archive behavior, extraction semantics, or output schema changes.

Follow the contribution scope. Routine malformed-input fix within the existing PyInstaller reader; a maintainer scope decision is not applicable. No related issue; found by reading the parser against the PyInstaller sources above.

Contract and boundary impact

  • Semantic owner and earliest changed stage: tocName at the CArchive TOC parsing boundary.
  • Contribution scope fit and linked maintainer decision: ordinary artifact-format validation; not applicable.
  • CLI and MCP/tool-catalog contract: malformed CArchives return the existing typed format failure instead of an accepted or invented member.
  • Provider, bridge, target-format, or platform compatibility: valid PyInstaller 2.0 and 2.1 CArchives are unchanged.
  • Evidence, artifact, provenance, or reconstruction contract: no evidence is published for the malformed TOC row.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none.

Expected effects (check known effects; use documentation-only on its own). Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: src/artifacts/pyinstaller/PyInstallerFormatBoundaries.test.ts ("rejects a CArchive TOC name without its required NUL terminator", "rejects a CArchive TOC name with non-NUL padding").
  • Base reproduction: on base 96ad94f6 with the CArchiveLayout.ts change reverted, npx vitest run src/artifacts/pyinstaller/PyInstallerFormatBoundaries.test.ts reported Tests 2 failed | 69 passed (71); both new tests failed with expected { ok: true, …(1) } to match object { ok: false, error: { …(2) } }.
  • User-visible CLI/MCP output (if applicable): malformed CArchive inspection returns the existing format failure, including table index 0 at TOC offset 0.
  • Remaining proof gaps: no external PyInstaller binary was run; validation uses the repository's synthetic format fixtures.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npx vitest run src/artifacts/pyinstaller/PyInstallerFormatBoundaries.test.ts with the fix reverted — 2 failed, 69 passed.
  • npx vitest run src/artifacts/pyinstaller/PyInstallerFormatBoundaries.test.ts with the fix — 71 passed.
  • npm run check:fast — passed (typecheck and lint).

Compatibility, safety, and release

  • Breaking changes or migration steps: malformed CArchives with an unterminated or nonzero-padded TOC name are now refused. Valid archives are unchanged.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable; ran on macOS with Node 24.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no target is run, attached, mutated, or contacted.

Author readiness

Human owner:

  • 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.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

Activity

8
chatgpt-codex-connector[bot]1mo ago

Codex Review Summary

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

ReviewStatusCommitReview trigger
📝 Code Review⚠️ Failed 2026-10-27T04:55:12.293281Z
We couldn’t complete this review. Comment @codex review to try again.
f90dafcDraft 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.

chatgpt-codex-connector[bot]1mo ago

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. Repo admins can enable using credits for code reviews in their settings.

greptile-apps[bot]1mo ago

Confidence Score: 5/5

[Medium impact] No blocking code issues were found; the declared readiness and CI gates still need to be completed.

Summary

CArchiveLayout rejects names without a NUL terminator or with nonzero padding. Valid zero-padded names remain accepted.

  • PyInstaller entries require names with NUL terminators and zero padding.
  • Import and expression cleanup leaves the app's behavior unchanged.

Reviews (3) · Last reviewed commit: "test(pyinstaller): assert framing error ..." · Reviewed by Greptile

This pull request is a draft

Merging is unavailable until it is marked ready for review.