Skip to content

fix(plist): record dictionary keys declared more than once - #10737

Merged
morluto merged 2 commits into
mainfrom
fix/plist-duplicate-key-detection
Nov 15, 2026
Merged

morluto merged 2 commits into
mainfrom
fix/plist-duplicate-key-detection

Conversation

@morluto

@morluto morluto commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

inspect_plist decodes binary, XML and OpenStep plists into a JSON value with one property per dictionary key. A dictionary that declares the same key twice silently lost the earlier value: the result looked complete and nothing said a declaration was dropped. The decoders now read each dictionary's source keys before the collapse and the result carries a counted limitation naming the repeated keys.

Refs the W7 duplicate-key workstream (structural audit report 06, finding 5: "Plist: a later duplicate key replaces the earlier one", BinaryPlistMaterializer.ts).

Problem and expected behavior

Trigger: an XML plist <dict><key>a</key><string>first</string><key>a</key><string>last</string></dict> (or a binary plist whose dictionary references the key string a twice, or OpenStep { a = 1; a = 2; }).

Before: { "a": "last" } with no limitation. The earlier declaration is gone and other plist readers (CoreFoundation, Python's plistlib) are free to keep a different one.

After: the value is unchanged (last still wins, so existing consumers see the same data), and limitations gains:

1 dictionary(ies) declare a key more than once ("a"). REA kept the last value for each key; 1 earlier value(s) are not reported, and other plist readers may keep a different one.

Change and scope

  • src/domain/apple/plistDuplicateKeys.ts (new) owns the fact: a collector that receives each dictionary's keys in source order, and the limitation text. Counts are exact; at most 8 distinct names are listed, each shortened to 64 characters with a marker, and ", ..." appears only when a further distinct repeated name was left out.
  • Each decoder reports keys at the point it builds a dictionary:
    • XML (propertyListXml.ts): from the entries list before Object.fromEntries.
    • OpenStep (propertyListOpenStep.ts): an optional collector parameter; keys are recorded as members are defined.
    • Binary (BinaryPlistMaterializer.ts): binaryPlistDuplicateKeys(plan) reads the planned dictionary containers' decoded keys, the same keys the materializer assigns.
  • ParsedPropertyList gains duplicateKeys; parsePlistBinary and the XML projection in src/native/parsers/plist.ts add the limitation.
  • Docs: a paragraph in docs/guides/native/native-investigation.md.

Not included:

  • JSON plist sources and plists decoded through a plutil conversion are not checked: JSON.parse and CoreFoundation have already kept one value per key before REA sees the text. The doc states this. The JSON reader belongs to the separate Keyed/duplicate-detecting JSON reader slice.
  • Other parseXmlPropertyList / decodeBinaryPlistValue consumers (keyed archives, Interface Builder, app bundle Info.plist executable lookup) receive the new field but do not yet surface it. They are follow-ups once the Keyed<T> owner lands.
  • No change to which value wins.

Contribution scope: ordinary fix within an existing boundary; not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: the plist decoders (XML, OpenStep, binary plan) own key identity; plistDuplicateKeys.ts owns the duplicate fact and its limitation; src/native/parsers/plist.ts projects it into ParsedPlist.limitations.

  • Contribution scope fit and linked maintainer decision: within existing inspect_plist boundary; W7 part 6 decision ("plist: detect duplicate keys before the plist library collapses them and record a limitation").

  • CLI and MCP/tool-catalog contract: no schema change; inspect_plist can return one more limitation string.

  • Provider, bridge, target-format, or platform compatibility: none.

  • Evidence, artifact, provenance, or reconstruction contract: decoded values unchanged; the limitation makes the loss visible.

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

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

  • 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/native/parsers/plist.test.ts: binary dictionary with a repeated stored key, XML source with a repeated key, distinct keys (including the same key in a nested dictionary) produce no limitation, OpenStep counts across two dictionaries.
    • src/domain/propertyListKeys.test.ts: the existing last-value-wins cases (split __proto__ keys, mixed CDATA/comment spellings, empty keys, OpenStep __proto__ and compound keys) now also assert the duplicate count and names.
  • Base reproduction: with the source changes reverted and the new tests kept, the 3 detection tests in plist.test.ts fail (no limitation / no duplicateKeys).

  • User-visible output: one added limitation string, shown above.

  • Remaining proof gaps: no real CoreFoundation comparison of which value it keeps; the limitation deliberately does not claim one.

  • 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:local -- src/native/parsers/plist.test.ts — 66 passed; 3 new tests fail with the source change reverted.

  • npm run test:local -- src/domain/propertyListKeys.test.ts plus every test file importing the XML/OpenStep decoders and src/artifacts/apple/PropertyListDecodeBudget.test.ts — 9 files, 317 passed.

  • npm run test:focused -- tests/boundary/providers/native/{nativePlistBinarySource,nativePlistDiagnostics,nativePlistFileCleanup,nativePlistSelection,nativePlistTextSource,plistSourceFormat}.test.ts src/artifacts/apple/PropertyListDecodeBudget.test.ts — 7 files, 86 passed.

  • npm run typecheck — passed. npx oxlint on changed files — no errors. npx oxfmt --check src docs/guides/native/native-investigation.md — clean.

  • node scripts/verify/architecture-guards.mjs — passed. npm run docs:check — passed.

  • Review follow-up (1d29219): npm run test:local -- src/native/parsers/plist.test.ts src/domain/propertyListKeys.test.ts — 113 passed; typecheck and oxlint clean.

Compatibility, safety, and release

  • Breaking changes or migration steps: none; values unchanged, one additive limitation.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable; the binary/XML/OpenStep paths are REA's own decoders.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no new reads or processes.

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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T02:23:09.999409Z 1d29219 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 Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

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

Summary

The PR records repeated dictionary keys in binary, XML, and OpenStep plists without changing which value wins.

  • Plist inspection reports repeated dictionary keys without changing the kept value.

Reviews (2) · Last reviewed commit: "fix(plist): bound repeated key names in ..." · Reviewed by Greptile

Comment thread src/domain/apple/plistDuplicateKeys.ts Resolved
Comment thread src/domain/apple/plistDuplicateKeys.ts Resolved
@morluto
morluto merged commit 4673457 into main Nov 15, 2026
52 of 54 checks passed
@morluto
morluto deleted the fix/plist-duplicate-key-detection branch November 15, 2026 05:45
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Nov 22, 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.

1 participant