Skip to content

fix(apple): report __proto__ entries omitted from OpenStep property lists - #4105

Merged
kaoru0822-kitauji merged 2 commits into
mainfrom
fix/3892-openstep-proto-omission
Oct 15, 2026
Merged

kaoru0822-kitauji merged 2 commits into
mainfrom
fix/3892-openstep-proto-omission

Conversation

@kaoru0822-kitauji

@kaoru0822-kitauji kaoru0822-kitauji commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #3892. An OpenStep-format keyed archive with a __proto__ dictionary key lost that entry without any omission limitation. The same archive converted to XML reports 1 dictionary entry keyed __proto__ was omitted…. OpenStep inputs now report the same omission.

Problem and expected behavior

parseXmlPropertyList (src/domain/propertyListKeys.ts) sends OpenStep text to the pinned plist decoder. It then counts own __proto__ properties with omitPrototypeKeys. The decoder (parse-openstep.js) assigns obj[key] = value, so a __proto__ key never becomes an own property:

  • a string value is ignored;
  • a dictionary value replaces the object's prototype.

In both cases the count was always 0. A decoded-value walk cannot recover a string-valued entry, so the source has to be counted.

Reproduced with the issue's archive and a real /usr/bin/plutil -convert xml1 copy, through rea inspect-keyed-archive --json:

input main this PR
OpenStep object 1 {"kept":"visible"}, truncated: false, no omission limitation, 2,274 bytes, 492 ms same object, 1 dictionary entry keyed __proto__ was omitted because REA results cannot represent that key., 2,466 bytes, 442–455 ms (warm)
XML (plutil) object 1 {"kept":"visible"}, omission limitation, 2,470 bytes, 470 ms unchanged (473 ms)

The OpenStep output grows only by the limitation that was missing. Timing is unchanged.

Change and scope

  • The existing OpenStep pre-scan already walks every dictionary key to bound nesting before the recursive decoder runs. It is renamed scanOpenStep and now also returns the number of keys that decode to __proto__:
    • unquoted keys compare as written;
    • quoted keys without escapes compare their contents;
    • quoted keys with escapes, and compound keys (a container opened in key position, such as (__proto__)), are decoded by the pinned decoder's own exported parseOpenStep and counted when String(value) is __proto__, the same coercion obj[key] performs, so REA does not reinterpret escapes or coercion. For example, "\_\_proto__" counts, while "\137_proto__" decodes to 137_proto__ and does not.
  • parseXmlPropertyList reports that count for OpenStep. It still returns the omitPrototypeKeys rebuild, which yields plain objects even when a key replaced a prototype.
  • The XML and binary paths are unchanged.

Contract and boundary impact

  • Semantic owner and earliest changed stage: shared property-list parsing (parseXmlPropertyList / OpenStep pre-scan), used by keyed archives and the other plist consumers.

  • Contribution scope fit and linked maintainer decision: a bug fix within the existing static, read-only boundary; not applicable.

  • CLI and MCP/tool-catalog contract: schemas unchanged. An OpenStep result with such keys gains the existing omission limitation.

  • Provider, bridge, target-format, or platform compatibility: OpenStep plists only.

  • Evidence, artifact, provenance, or reconstruction contract: omissions are now disclosed instead of silent.

  • Target selection, authority, upstream behavior, and cleanup details: not applicable.

  • Generated metadata, package, or installation impact: none.

  • Read existing files or captured data.

Evidence and regression coverage

  • Tests added or updated: src/domain/propertyListKeys.test.ts adds one case that counts four keys decoding to __proto__: unquoted, quoted, escape-spelled, and a nested key with a dictionary value. The case also checks that a __proto__ value, an array element __proto__ and "\137_proto__" are not counted, and that the nested object keeps Object.prototype. It fails on main (count 0) and passes with the fix.
  • Real tooling: the XML control was produced by Apple plutil, and both files were inspected through the built CLI as tabulated.
  • Remaining proof gaps: no shipped OpenStep keyed archive containing __proto__ was available.

Validation performed

  • npx vitest run src/domain/propertyListKeys.test.ts — 38 passed; against main, 1 failed as expected.
  • npx vitest run src/domain src/artifacts/apple tests/boundary/filesystem — 376 files: 5,902 passed, 2 failed. The two failures (productCatalog.test.ts, setupSkill.test.ts) compare against generated artifacts that were stale in my local checkout. They pass under npm run test:focused -- tests/boundary/filesystem/productCatalog.test.ts tests/boundary/filesystem/setupSkill.test.ts (26 passed), which regenerates those artifacts, and neither involves this change.
  • npm run check:fast — passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: macOS plutil for the control file.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no change in how values are decoded. The rebuild still prevents prototype pollution from reaching results.

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.

🤖 Generated with Claude Code

…ists

The pinned OpenStep decoder assigns a `__proto__` dictionary key to the
object's prototype, so the entry vanished before REA could count it and
OpenStep keyed archives reported no omission, unlike the same archive in
XML. The OpenStep pre-scan, which already walks every key for the depth
limit, now counts keys that decode to `__proto__`; quoted keys with
escapes are decoded by the pinned decoder itself. The rebuilt value still
drops any prototype a key replaced.

Fixes #3892

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kaoru0822-kitauji kaoru0822-kitauji added the track:perf Performance track PRs (issues & perf loop) label Oct 15, 2026

@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: beba6611a8

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

Comment on lines +212 to +213
if (parent?.next === "key") {
if (isOpenStepPrototypeKey(text.slice(cursor, end))) prototypeKeys += 1;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Count compound keys that coerce to __proto__

A valid OpenStep compound dictionary key such as (__proto__) = hidden; is accepted by the same grammar covered by the existing compound-key test, and the decoder's obj[key] = value coerces its one-element array key to __proto__, silently dropping or replacing the prototype. This branch only counts scalar tokens while the dictionary is awaiting a key; the opening ( bypasses it and __proto__ is scanned as an array element, so this input still reports zero omissions. Count compound keys after their decoded property-key coercion as well.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Valid, fixed in 8045be3. Root cause: the scan only checked scalar tokens in key position, but the decoder's obj[key] = value coerces any key to a property name. A one-element array key such as (__proto__) therefore becomes __proto__. A container opened while its dictionary awaits a key now records its start offset. When it closes, its source is decoded by the pinned decoder's parseOpenStep and counted when String(value) === "__proto__", the same coercion the assignment performs, so REA does not reimplement it. isOpenStepPrototypeKey uses the same rule for escaped quoted keys. New test: (__proto__) and (("__proto__")) are counted. ("__pro", "to__") (key __pro,to__) and the value list = (__proto__) are not. Both counted cases fail on beba661. Validation: npx vitest run src/domain src/artifacts/apple passed 188 files (3,274 tests), npm run check:fast passed, and the issue's CLI repro still reports one omission.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 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-15T12:55:42.218120Z 8045be3 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.

@greptile-apps

greptile-apps Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous compound-key issue is addressed.

Summary

OpenStep property lists now report omitted __proto__ entries, including compound keys that become that name.

  • OpenStep plist parsing reports __proto__ keys lost during decoding.

Reviews (2) · Last reviewed commit: "fix(apple): count OpenStep compound keys..." · Reviewed by Greptile

Comment thread src/domain/propertyListKeys.ts Resolved
Review follow-up. A compound dictionary key such as `(__proto__)` is
coerced by the decoder's `obj[key]` assignment to the property name
__proto__, but the scan only checked scalar keys. Containers opened in
key position are now decoded by the pinned decoder on close and counted
when their property-name coercion is __proto__.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kaoru0822-kitauji
kaoru0822-kitauji merged commit fe7bcc3 into main Oct 15, 2026
32 of 33 checks passed
@kaoru0822-kitauji
kaoru0822-kitauji deleted the fix/3892-openstep-proto-omission branch October 15, 2026 13:12
@JFSAS JFSAS mentioned this pull request Oct 15, 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 track:perf Performance track PRs (issues & perf loop)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] OpenStep keyed archives drop __proto__ entries without an omission limitation

2 participants