Skip to content

fix(plist): read XML plists containing a __proto__ key - #885

Merged
kaoru0822-kitauji merged 1 commit into
mainfrom
fix/plist-prototype-keys
Oct 7, 2026
Merged

kaoru0822-kitauji merged 1 commit into
mainfrom
fix/plist-prototype-keys

Conversation

@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

Summary

__proto__ is a legal plist dictionary key (plutil -lint reports OK), but the plist package's XML decoder throws on it (__proto__ keys can lead to prototype pollution. More details on CVE-2022-22912). Every REA site that decodes XML plists failed on such a key:

Site Before
App target resolution (XML Info.plist, from #857) The app could not be opened at all: target_unavailable, app has no readable CFBundleExecutable. One unrelated <key>__proto__</key> is enough to keep an app out of every REA tool.
inspect_plist, plutil XML route (data/date/large-integer plists) app has no readable CFBundleExecutable / decode failure
inspect_plist, plutil JSON route key silently dropped, because zod record/object parsing strips own __proto__ keys
inspect_signature entitlements, XML inspect_keyed_archive, Interface Builder plists decode failure

A new shared reader, src/domain/propertyListKeys.ts, swaps each element key that decodes to __proto__ (literal, entity-encoded, or CDATA) for a unique placeholder before the plist decoder runs. Comments and CDATA text are consumed whole, so only real <key> elements are touched. The reader then omits those entries and returns how many it dropped. REA results cannot carry the key, because validation strips it, so it is reported rather than invented:

  • inspect_plist (both routes) and inspect_keyed_archive (XML) add the limitation 1 dictionary entry keyed __proto__ was omitted because REA results cannot represent that key.
  • Target resolution, entitlements, and Interface Builder decoding no longer fail. They read the other entries.

Prototype safety is unchanged: entries are rebuilt with Object.fromEntries, and the omitted value is never assigned.

Not covered: the plist package's binary decoder assigns dict["__proto__"] = value, which silently drops the key or replaces the object's prototype. Binary keyed archives and binary NIB plists are therefore unchanged by this PR. Binary Info.plist and inspect_plist go through plutil and are covered.

No schema or catalog change.

Verification

  • tests/boundary/filesystem/binaryTarget.test.ts: an app opens when its XML Info.plist also holds a literal or entity-encoded __proto__ entry, including one whose value contains a forged CFBundleExecutable. Fails on main.
  • New tests/boundary/cli/nativePlistPrototypeKeyCli.test.ts (darwin, real plutil): JSON-expressible and data-bearing plists inspect successfully with the limitation, and the omitted value does not appear. Fails on main.
  • src/artifacts/KeyedArchiveReader.test.ts: an XML archive with a __proto__ entry decodes and reports the limitation. Fails on main.
  • New src/domain/propertyListKeys.test.ts covers the literal, CDATA, and entity spellings. It also checks that comments, CDATA strings, __proto__ with spaces, and the placeholder spelling itself stay intact.
  • npm run check:changed (22 files, 164 tests), npm run docs:check, npm run verify:keyed-archive (real Foundation), and the native plist/signature/keyed-archive/provider boundary tests all pass. 7 NIB/storyboard tests fail identically on unmodified main on this host, because this Mac has only the Command Line Tools and no ibtool.

No Hopper/Ghidra/IDA verification is needed.

🤖 Generated with Claude Code

The `plist` XML decoder throws on the legal dictionary key `__proto__`
(its CVE-2022-22912 guard). An app whose XML Info.plist held such an
entry could not be opened at all ("app has no readable
CFBundleExecutable"), and entitlements, XML keyed archives, and
Interface Builder plists failed the same way. On the plutil JSON route,
validation silently dropped the key from `inspect_plist` results.

Decode XML plists through a shared reader that substitutes such keys
before the decoder runs, then omits and counts those entries.
`inspect_plist` and `inspect_keyed_archive` report the omission as a
limitation instead of failing or dropping it silently.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 7, 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-07T07:01:52.517077Z a08be51 PR opened
ℹ️ 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: a08be51e9f

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

if (start < 0 || end < start) return null;
return jsonValueSchema.parse(
parseXmlPlist(output.slice(start, end + "</plist>".length)),
parseXmlPropertyList(output.slice(start, end + "</plist>".length)).value,

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 Report omitted keys in signature results

When codesign emits an entitlements plist containing a __proto__ key, this extracts only .value and discards omittedPrototypeKeys; #inspectSignature therefore returns a successful but incomplete entitlement set without adding anything to limitations. Propagate the omission count into the signature result so analysts are not led to treat the remaining entitlements as complete.

AGENTS.md reference: AGENTS.md:L54-L58

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.

Agreed. #885 merged before I got to this. #894 has the fix: inspect_signature now adds Entitlements: 1 dictionary entry keyed __proto__ was omitted because REA results cannot represent that key.

bytes.subarray(0, 8).toString("ascii") === "bplist00"
? parseBinary(bytes)
: parse(bytes.toString("utf8"));
: parseXmlPropertyList(bytes.toString("utf8")).value;

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 Mark Interface Builder results partial after omitting keys

For an XML NIB containing a __proto__ key, this discards omittedPrototypeKeys and returns the reduced object as a successfully decoded document. Consequently archive_decode can remain complete and the result has no limitation even though archive data was removed; carry the omission metadata into the analysis coverage and limitations.

AGENTS.md reference: AGENTS.md:L54-L58

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.

Agreed, fixed in #894. decode_interface_builder marks archive_decode partial with reason dictionary_entries_omitted, sets graph.truncated, and adds a per-document limitation.

Comment on lines +78 to +79
let placeholder = "__rea_prototype_key__";
while (text.includes(placeholder)) placeholder = `_${placeholder}`;

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 Reserve placeholders using decoded key values

The collision check searches raw XML text, so a legitimate key such as <key>&#95;&#95;rea_prototype_key__</key> does not match text.includes(placeholder) but is decoded by the plist parser to the chosen placeholder. withoutKey then removes that unrelated entry and falsely reports it as an omitted __proto__ key, even when no such key existed; determine collisions from decoded <key> values or use a substitution that cannot alias source keys.

AGENTS.md reference: AGENTS.md:L54-L56

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.

Agreed, fixed in #894. The placeholder is now reserved against the entity-decoded text, so <key>&#95;&#95;rea_prototype_key__</key> is kept and only the real __proto__ entry is omitted.

@kaoru0822-kitauji
kaoru0822-kitauji merged commit faaee69 into main Oct 7, 2026
19 checks passed
@kaoru0822-kitauji
kaoru0822-kitauji deleted the fix/plist-prototype-keys branch October 7, 2026 07:46
AkumaHalls pushed a commit to AkumaHalls/rea that referenced this pull request Oct 7, 2026
…ace Builder

morluto#885 decodes XML plists that contain a __proto__ key by omitting those
entries, but signature entitlements and Interface Builder plists dropped
the omission count. inspect_signature returned an entitlement set that
looked complete, and archive_decode stayed complete. Both now report the
omission: a signature limitation, and a partial archive_decode facet with
reason dictionary_entries_omitted and a per-document limitation.

The placeholder that stands in for __proto__ was reserved against the raw
XML text, so an entity-encoded key such as &morluto#95;&morluto#95;rea_prototype_key__
decoded to the placeholder and was omitted as if it were __proto__. The
placeholder is now reserved against the decoded text.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
darsrc pushed a commit to darsrc/rea that referenced this pull request Oct 10, 2026
fix(plist): read XML plists containing a __proto__ key
darsrc pushed a commit to darsrc/rea that referenced this pull request Oct 10, 2026
…ace Builder

morluto#885 decodes XML plists that contain a __proto__ key by omitting those
entries, but signature entitlements and Interface Builder plists dropped
the omission count. inspect_signature returned an entitlement set that
looked complete, and archive_decode stayed complete. Both now report the
omission: a signature limitation, and a partial archive_decode facet with
reason dictionary_entries_omitted and a per-document limitation.

The placeholder that stands in for __proto__ was reserved against the raw
XML text, so an entity-encoded key such as &morluto#95;&morluto#95;rea_prototype_key__
decoded to the placeholder and was omitted as if it were __proto__. The
placeholder is now reserved against the decoded text.
@morluto morluto added the bug Something isn't working label Oct 14, 2026
@morluto morluto added the area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior label Nov 26, 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.

2 participants