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

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 <noreply@anthropic.com>
This commit is contained in:
Iwakurakaoru0822
2026-10-06 23:58:59 -07:00
co-authored by Claude Opus 5.5
parent 507e8b3c7b
commit a08be51e9f
10 changed files with 278 additions and 28 deletions
@@ -0,0 +1,53 @@
import { mkdir, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { describe, expect } from "vitest";
import { thinMach } from "../../../src/domain/binaryTarget.fixture.js";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
import { cliTest } from "../../support/cli/cliFixture.js";
const OMITTED =
"1 dictionary entry keyed __proto__ was omitted because REA results cannot represent that key.";
describe.skipIf(process.platform !== "darwin")(
"native plist CLI with a __proto__ key",
() => {
cliTest.for([
["JSON-expressible", ""],
["data-bearing", "<key>Blob</key><data>AAEC</data>"],
] as const)(
"inspects a $0 plist and reports the omitted key",
async ([, extra], { cli }) => {
const directory = await createTestTempDirectory("rea-plist-proto-");
const app = join(directory, "Proto.app");
const contents = join(app, "Contents");
await mkdir(join(contents, "MacOS"), { recursive: true });
await writeFile(
join(contents, "MacOS/App"),
thinMach(0xfeedfacf, 0x100000c),
);
await writeFile(
join(contents, "Info.plist"),
`<plist><dict><key>CFBundleExecutable</key><string>App</string><key>__proto__</key><dict><key>polluted</key><true/></dict>${extra}</dict></plist>`,
);
const result = await cli.run({
arguments: ["inspect-plist", app, "--json"],
environment: {
REA_LOG_LEVEL: "silent",
REA_ANALYSIS_PROVIDER: "auto",
},
});
expect(result.exitCode).toBe(0);
expect(result.json).toMatchObject({
normalized_result: {
value: { CFBundleExecutable: "App" },
bundle: { executable: "App" },
limitations: expect.arrayContaining([OMITTED]),
},
});
expect(JSON.stringify(result.json)).not.toContain("polluted");
},
);
},
);