Skip to content

fix(apple): preserve 128-bit keyed archive integers - #4324

Merged
morluto merged 5 commits into
morluto:mainfrom
pollychen-lab:agent/keyed-archive-uint64-4292
Oct 16, 2026
Merged

morluto merged 5 commits into
morluto:mainfrom
pollychen-lab:agent/keyed-archive-uint64-4292

Conversation

@pollychen-lab

@pollychen-lab pollychen-lab commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #4292. Binary keyed archives with 16-byte integer markers no longer report UInt64 values such as 18446744073709551615 as an observed zero. Adjacent large integers retain exact decimal values too.

Problem and expected behavior

The pinned plist decoder read only the first eight bytes of a 16-byte integer. For UInt64.max that produced zero, while the raw metadata scan marked the whole table incomplete. The result should preserve exact decimal text when the original integer bytes identify it unambiguously.

Change and scope

The bounded binary number scan now recognizes signed 128-bit integer markers. Before rewriting a parser-compatible copy, it validates object extents and refuses rewriting when object-table entries overlap. The decode budget reserves the possible input-sized copy before allocation. Exact integers are restored from metadata scanned from the original bytes, preserving source bytes and digest. Both keyed archive and Interface Builder decode paths use this handling. No schema or tool contract changes.

This is a focused static plist decoding fix; no maintainer scope decision applies. It reads local artifact bytes and does not launch a target process or contact a service.

Evidence and regression coverage

  • Before the change, the public CLI reproduced [Bug] Binary keyed archives report integers above Int64.max as 0 #4292 on a generated binary NSKeyedArchiver fixture: UInt64.max was value: 0 with status: "observed", and adjacent Int64.max was rounded.
  • A generated fixture exercises the public CLI and filesystem boundary. Both values are asserted as exact decimal wrappers, with no incomplete-number-metadata limitation.
  • A malformed object table with an unused integer offset inside a data object verifies that overlapping source bytes are never rewritten.
  • Budget coverage verifies binary number projection reserves at least one additional input-sized buffer.
  • A 32 MiB synthetic plist with one wide integer caused a 33,423,360-byte RSS increase when the compatibility copy was created (one Node 24.18.0 sample; the copy itself was 33,554,510 bytes).
  • No Apple Foundation or plutil runtime was available here; the fixture is generated with the bplist encoding and validated through REA's production CLI.

Validation performed

  • npm run compile — passed.
  • npm run test:focused -- src/artifacts/apple/PlistNumberLiterals.test.ts src/artifacts/apple/InterfaceBuilderDecodeBudget.test.ts src/artifacts/apple/KeyedArchiveReader.test.ts tests/boundary/filesystem/keyedArchiveNumberMetadata.test.ts src/browser/PlaywrightBrowserScenarioProvider.test.ts — 86 passed.
  • npm run check:fast — passed.
  • npm run format:check — passed.
  • Latest GitHub CI — source tests, static checks, package build, Windows fixture build, Linux native package baseline, and Greptile passed. The required suite remains red on unrelated tests: browser probe lifecycle, browser cancellation CLI, and capture cleanup failures also reproduce on base 1bd5c5c87; one ADB CLI test additionally failed on this run due to differing temporary input paths.

Compatibility and safety

No migration or schema changes. Numeric decoding of 16-byte binary plist integers becomes exact where source metadata is unambiguous. Overlapping object tables retain original bytes and are marked incomplete. Platform-specific Foundation writer verification was unavailable; the generated fixture and production CLI provide local coverage.

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.

@pollychen-lab
pollychen-lab marked this pull request as ready for review October 16, 2026 01:35
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 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 ⚠️ Failed 2026-10-16T04:07:18.377416Z 4230934 New commits
ℹ️ 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 chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 08e6d93dc4

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

metadata: BinaryPlistNumberMetadata,
): Buffer => {
if (metadata.wideIntegers.length === 0) return bytes;
const compatible = Buffer.from(bytes);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Charge the compatibility copy to the decode budget

When either inspected decode path sees even one wide integer, this line copies the entire input (up to 64 MiB for keyed-archive decoding, or 32 MiB aggregate for Interface Builder) after the existing preflight/reservation calculation; neither estimateBinaryPlistExpansion nor preflightPropertyListDecode charges the new buffer. A near-budget archive can therefore add an input-sized transient allocation beyond the modeled decode reservation, so charge this conditional copy before allocation (or avoid the full-file copy) and measure the new peak.

AGENTS.md reference: AGENTS.md:L77-L77

Useful? React with 👍 / 👎.

@greptile-apps

greptile-apps Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable issue was found.

Summary

Preserves exact decimal values for unambiguous 16-byte binary plist integers in keyed archives and Interface Builder files.

  • Binary plist decoding keeps exact values for 16-byte integers.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Original binary plist] --> B[Check decode budget]
  B --> C[Scan exact numbers and object boundaries]
  C --> D{Safe wide integers found?}
  D -->|Yes| E[Rewrite a copy for the parser]
  D -->|No| F[Keep original parser input]
  E --> G[Parse plist]
  F --> G
  C --> H[Original number metadata]
  G --> I[Project decoded values]
  H --> I
  I --> J[Restore unambiguous exact decimals]
Loading

Reviews (3) · Last reviewed commit: "Merge origin/main into agent/keyed-archi..." · Reviewed by Greptile

@kaoru0822-kitauji kaoru0822-kitauji added the ci-fix-wip Claimed by the CI-fix track label Oct 16, 2026
Main (morluto#4274) rewrote the active-action cancellation test for its new
cancellation semantics (partial observation on AnalysisCancelledError).
This branch had only adjusted that test around main's earlier red run,
so take main's version.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

Resolved the conflict with main. The only conflict was in PlaywrightBrowserScenarioProvider.test.ts, the browser cancellation test that was red on main. Main's #4274 rewrote it for its new cancellation semantics, so I took main's version, since this branch had only adjusted it around the earlier red run. The keyed-archive changes merged cleanly. Locally, PlistNumberLiterals, InterfaceBuilderDecodeBudget, the browser provider test and keyedArchiveNumberMetadata.test.ts all pass (68 tests), and typecheck passes.

@kaoru0822-kitauji kaoru0822-kitauji removed the ci-fix-wip Claimed by the CI-fix track label Oct 16, 2026
@morluto
morluto merged commit 44c9ff7 into morluto:main Oct 16, 2026
33 checks passed
@JFSAS JFSAS mentioned this pull request Oct 16, 2026
4 tasks done
@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
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] Binary keyed archives report integers above Int64.max as 0

3 participants