Repository navigation
fix(apple): preflight XML plist nesting before keyed archive decoding - #2161
Merged
morluto merged 2 commits intoOct 12, 2026
Merged
Conversation
inspect_keyed_archive documented a 128-level nesting limit, but the XML plist path reached recursive decoding before any depth check: plist and the prototype-key traversal in parseXmlPropertyList recurse once per nesting level, so a ~75 KiB, 3000-level XML plist exhausted the call stack and reported Maximum call stack size exceeded instead of the bounded-resource limit that shallower over-limit documents (129, 200) already produced. The CLI classified both as truncated, so no crash or classification bypass was involved; the diagnostic was the defect. Reject excessive nesting in parseXmlPropertyList before any recursive pass, using the projection's own limit (MAX_PLIST_DEPTH) so the error is identical to the one projectPlistValue raises: callers keep the limit/truncated classification with no error-handler translation. Depth counts values the way the projection does - container members nest one level deeper, dictionary keys name members rather than nesting, and a self-closing element is the value at its own level - so the guard rejects exactly the documents the projection rejected, at the same boundary, and every in-limit document decodes unchanged. The guard sits at the shared decoder boundary, so Interface Builder, app Info.plist resolution and native inspect_plist gain the same deterministic limit; the binary plist path keeps its existing expansion preflight. Binary plist behavior, ordinary XML decode, __proto__ omission counting, and archive digest/Evidence provenance are unchanged. OpenStep autodetection is untouched by this guard, as the existing Interface Builder preflight also scopes its depth check to XML. Regression coverage: decoder unit tests at and just past the limit for dictionary and array nesting with self-closing and opaque markup, module tests through decodeKeyedArchiveBytes including a valid NSKeyedArchiver XML envelope at the limit, a production-boundary test through inspectBundleKeyedArchive, and the compiled public CLI reporting code truncated / reason limit for a 3000-level plist.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Reuse the iterative XML decoder document for depth preflight and prototype-key lookup. Bound recursive plist wrappers alongside dictionaries and arrays without interpreting markup inside attributes or DOCTYPE declarations as values. Validated with 104 focused tests including compiled CLI, MCP prototype-key, and Interface Builder coverage; npm run check and verify:test-discovery passed. No real-provider verification was run.
3 tasks done
13 tasks done
Owner
|
@Zburgers, thank you for adding an iterative XML depth preflight before the plist decoder reaches its recursive passes. Sharing the projection’s 128-level limit means deeply nested files get the established bounded-resource diagnosis instead of an opaque stack-overflow message; the 3,000-level regression makes that failure mode tangible. Welcome to REA! |
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2105.
Problem
inspect_keyed_archive documents a 128-level nesting limit, but the XML plist path reached recursive decoding before any depth check. plist and the prototype-key traversal in parseXmlPropertyList recurse once per nesting level, so a ~75 KiB, 3,000-level XML plist exhausted the call stack and reported Maximum call stack size exceeded instead of the bounded-resource diagnostic that shallower over-limit documents (129, 200) already produced. The CLI classified both as runcated/limit, so this is not a crash or a classification bypass — the diagnostic was the defect. The binary plist path already had an expansion/depth preflight; the XML path did not.
Fix
�ssertXmlPlistDepthWithinLimit in src/domain/propertyListKeys.ts runs at the top of the XML branch of parseXmlPropertyList, before the DOM substitution and before plist.parse. It is a single-pass, iterative token scan that counts value nesting the way projectPlistValue does — container members nest one level deeper, dictionary keys name members rather than nesting them, and a self-closing element is the value at its own level — and throws the projection's own RangeError("Plist exceeds 128 nesting levels") against the shared, now exported MAX_PLIST_DEPTH.
Consequences of that shape:
The XML token pattern mirrors the existing Interface Builder estimator. OpenStep autodetection is untouched by this guard, matching the existing preflight's XML-only depth scope.
Behavior
Before vs. after on the issue's synthetic fixtures (exit code 1 in both cases):
Top-level code: "truncated", category: "truncated", details.reason: "limit" are unchanged; only the 3,000+ diagnostic becomes the documented limit.
Tests
Validation
pm run test:local (source tests), plus targeted �dapters, domain, �oundary, cli-boundary, and mcp-boundary runs for keyed-archive suites. Pre-existing environmental failures on this host (Windows native addon/IDA/setup-TTY dependent files) were confirmed identical on a pristine main checkout and are unrelated.
Not covered here
pm run verify:keyed-archive) requires macOS/Xcode and was not run; the portable CLI boundary test covers the public path instead.