fix(apple): bound bundle Info.plist reads before decoding (#12279)

* fix(apple): bound bundle Info.plist reads before decoding

* refactor(apple): report plist input limits through shared failures

* fix(apple): retain bundle plist descriptors through target cleanup

* test(apple): verify Hopper retries bundle plist cleanup

* fix(apple): preserve typed cancellation through bundle plist cleanup

* fix(apple): preserve plist read failure through late cancellation

* fix(apple): preserve cancellation during plist close retry

* docs(apple): document bundle plist admission policy

---------

Co-authored-by: ShuaixinHuang <197200901+ShuaixinHuang@users.noreply.github.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2026-11-19 13:41:40 +00:00
1 parent 0a9f22847d
commit a44ff73676
9 files changed
+512 -62

No files matched your search

+38 -12
View File
@@ -1,4 +1,4 @@
import { mkdtemp, mkdir, rm, writeFile } from "node:fs/promises";
import { mkdtemp, mkdir, rm, truncate, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
@@ -61,6 +61,30 @@ it.each([
},
);
it("reports an oversized Info.plist as an input refusal before decoding", async () => {
const root = await createTestTempDirectory("rea-app-plist-input-");
const bundle = join(root, "Fixture.app");
const plist = join(bundle, "Contents", "Info.plist");
await mkdir(join(bundle, "Contents"), { recursive: true });
await writeFile(plist, "");
await truncate(plist, 64 * 1024 * 1024 + 1);
expect(await resolveAppleBundleExecutable(bundle)).toMatchObject({
ok: false,
error: {
path: plist,
reason: expect.stringContaining("67108864-byte input allowance"),
cause: {
name: "ParseFailureError",
kind: "limit",
failure: {
limit: { maximum: 64 * 1024 * 1024, required: 64 * 1024 * 1024 + 1 },
},
},
},
});
});
describe("app bundle Info.plist magic", () => {
it("decodes an executable when an unrelated UID uses a three-byte width", async () => {
const root = await createTestTempDirectory("rea-app-three-byte-uid-");
@@ -139,17 +163,19 @@ describe("app bundle program directory containment", () => {
let childResolved = false;
const result = await resolveAppleBundleExecutable(bundle, {
readFile: async () => Buffer.from(plist),
realpath: async (path) => {
if (path === bundle) return canonicalBundle;
if (path === programs) return outsidePrograms;
if (path === executable) {
childResolved = true;
throw Object.assign(new Error("missing executable"), {
code: "ENOENT",
});
}
return path;
fileSystem: {
readFile: async () => Buffer.from(plist),
realpath: async (path) => {
if (path === bundle) return canonicalBundle;
if (path === programs) return outsidePrograms;
if (path === executable) {
childResolved = true;
throw Object.assign(new Error("missing executable"), {
code: "ENOENT",
});
}
return path;
},
},
});