Skip to content

fix(apple): preserve post-table plist objects - #7820

Merged
morluto merged 1 commit into
mainfrom
codex/fix-plist-post-table
Oct 28, 2026
Merged

morluto merged 1 commit into
mainfrom
codex/fix-plist-post-table

Conversation

@morluto

@morluto morluto commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes #7348. A binary keyed archive whose object data follows its offset table can report the original string as an observed null when REA normalizes an unusual offset width. The decoder copy now retains the original object offsets and returns the string.

Problem and expected behavior

An admitted three-byte table followed by a hello object moved that object while keeping its old offset. The private decoder copy must preserve the selected artifact's values and the original bytes.

Change and scope

Append replacement records and a fresh offset table after the original bytes before the trailer. Calculate the required width and charge the added representation before allocation. Clone-layout tests read offsets from the produced table instead of assuming where a clone is placed.

PR #7166 addresses a separate table/trailer overlap and touches the same owner; its description explicitly excludes this post-table relocation. The two changes need reconciliation if both are merged.

Contract and boundary impact

  • Semantic owner and earliest changed stage: binary plist private decoder-copy construction and its allocation preflight; keyed archive and Interface Builder consumers retain their existing contracts.
  • Contribution scope fit and maintainer decision: passive reads within existing boundaries; no new capability decision applicable.
  • CLI and MCP/tool-catalog contract: no schema change; incorrect observed values become the serialized values.
  • Provider, bridge, target-format, or platform compatibility: binary plist layouts with 1-, 3-, and 4-byte offset entries are covered.
  • Evidence, artifact, provenance, or reconstruction contract: the selected archive remains unchanged; observations derive from its original objects.
  • Target selection, authority, upstream behavior, and cleanup details: no target execution or mutation.
  • Generated metadata, package, or installation impact: none.

Expected effects:

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

Evidence and regression coverage

  • Tests added or updated: public CLI controls for post-table strings and pre-table data; scalar clone layout tests use actual parsed offsets.
  • Base evidence: source-derived failure and independently decoded fixture in [Bug] Keyed-archive table normalization changes a post-table string to observed null #7348; this branch's CLI returns observed hello for all controls.
  • User-visible output: keyed archive object 1 reports status: observed, value: hello.
  • Remaining proof gaps: native Foundation acceptance and real-exporter prevalence are unknown; no separate MCP workflow ran.

Boundary coverage includes unusual offset widths, before/after-table layouts, unchanged source bytes and the existing capacity checks. No lifecycle change is involved.

  • 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

  • npm run test:focused -- tests/acceptance/applications/keyedArchivePostTable.test.ts — passed; CLI checks three post-table widths and a pre-table control, including unchanged input bytes.
  • npm run test:local -- src/artifacts/apple/PlistScalars.test.ts src/artifacts/apple/KeyedArchiveReader.test.ts src/artifacts/apple/InterfaceBuilderDecodeBudget.test.ts — 80 passed.
  • npm run check:fast and git diff --check — passed.

Compatibility, safety, and release

No intended breaking change, new authority or package impact. Native Foundation behavior and real-exporter frequency were not verified; the fixture is synthetic. MCP was not exercised independently.

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.

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.

@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The reviewed changes appear safe to merge.

Summary

The private binary plist decoder copy now preserves bytes before the trailer and appends replacement records and a fresh offset table.

  • Binary plist reads keep objects after the offset table in place.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Original bytes] --> B[Check required space]
  B --> C[Copy bytes before trailer unchanged]
  C --> D[Append replacement records]
  D --> E[Write fresh offset table]
  E --> F[Write updated trailer]
  F --> G[Decode using fresh offsets]
Loading

Reviews (1) · Last reviewed commit: "fix(apple): preserve post-table plist ob..." · Reviewed by Greptile

@morluto
morluto marked this pull request as ready for review October 28, 2026 15:40
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T15:41:43.340876Z 3f09d78 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.

@morluto
morluto merged commit 675c73f into main Oct 28, 2026
43 of 44 checks passed
@morluto
morluto deleted the codex/fix-plist-post-table branch October 28, 2026 20:59
devreddy1015 added a commit to devreddy1015/rea that referenced this pull request Oct 29, 2026
Review follow-up (Codex). Decoder bounds admit an offset table that runs
into the trailer and an object stored in the trailer's spare bytes after
it. With dates now observed for that layout, an overlapping
sub-millisecond date reaches cloneBinaryPlistObjects. Since morluto#7820 the
rewrite appends clones and a fresh table, but only after the bytes before
the trailer, so it overwrote such an object and plist@5 failed with
"Unsupported int size: 256".

Copy the whole source buffer and append the clones, the new table and a
new trailer after it. The old table and trailer stay as inert bytes, so
every source offset still names its original record. The offset width and
both preflight estimates now account for the clones starting at the end
of the buffer and for the extra trailer.
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Nov 23, 2026
morluto added a commit that referenced this pull request Nov 26, 2026
… the trailer (#7166)

* fix(apple): observe keyed-archive dates when the offset table reaches the trailer

inspect_keyed_archive preflights binary plists with decoder bounds, which
admit an offset table that ends anywhere before end of file, including
inside the 32-byte trailer. plist@5 reads such a table. Dates must still
end before the offset table, so the preflight records each reachable date.

The scalar scanner, however, required the table to end before the
trailer. For a table that runs into the trailer it abandoned the whole
file and collected no dates. The precision clamp in
decodeBinaryPlistScalars then saw no unrepresentable date, so a 0.1005 s
instant was reported as the exact timestamp 2001-01-01T00:00:00.100Z with
no unknown-date limitation.

Bound the scanner's offset-table reads by the end of the file, which is
the widest table any preflight admits. Strict preflight already rejects
tables past the trailer before scanning, so strict callers are unchanged.
Object and date bounds still end at the offset table.

* fix(apple): rebuild a complete trailer when cloning plist scalars

Review follow-up. With the scanner observing dates when the offset table
runs into the trailer, a sub-millisecond date that overlaps another object
now reaches cloneBinaryPlistObjects. That rewrite sized its output as
bytes.length plus the growth of a table assumed to end before the trailer.
When the old table overlaps the trailer, those bytes exist only once, so
the buffer came out short and the copied trailer was truncated. plist@5
then failed with "Unsupported int size: 0".

binaryPlistCloneGrowth now computes the bytes a clone rewrite adds,
subtracting only the old table bytes that precede the trailer. The
allocator and both preflight budget estimates use it, so admission and
allocation agree. For tables that end before the trailer the value is
unchanged.

* fix(apple): keep every source byte when cloning plist scalars

Review follow-up (Codex). Decoder bounds admit an offset table that runs
into the trailer and an object stored in the trailer's spare bytes after
it. With dates now observed for that layout, an overlapping
sub-millisecond date reaches cloneBinaryPlistObjects. Since #7820 the
rewrite appends clones and a fresh table, but only after the bytes before
the trailer, so it overwrote such an object and plist@5 failed with
"Unsupported int size: 256".

Copy the whole source buffer and append the clones, the new table and a
new trailer after it. The old table and trailer stay as inert bytes, so
every source offset still names its original record. The offset width and
both preflight estimates now account for the clones starting at the end
of the buffer and for the extra trailer.

* test(apple): match main's limitation assertions in keyed-archive date tests

* fix(apple): observe binary plist dates only when they end before the trailer

---------

Co-authored-by: morluto <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Keyed-archive table normalization changes a post-table string to observed null

1 participant