fix(artifacts): harden xar and cpio readers for hostile packages
Address review findings in PKG inventory: - Read the xar TOC checksum only when its declared size equals the algorithm's digest length. A crafted size can no longer trigger a huge allocation. - Associate cpio hard links whose bytes are stored on another member (newc stores them on the last link). Linked bytes are kept, within 16 MiB per member and 64 MiB in total, and served to every path. A link whose bytes never appear is recorded with content unavailable and a limitation, not hashed as an empty file. ArtifactEntry gains `contentUnavailable` for this. - Verify `070702` member CRCs whether or not a member is opened. - Report malformed zlib members as `format`, and keep cancellation as `cancelled` while loading, opening, or streaming members. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
54dd1a7604
commit
daf504b62f
@@ -117,4 +117,34 @@ describe("installer package inventory", () => {
|
||||
details: { reason: "integrity" },
|
||||
});
|
||||
});
|
||||
|
||||
it("records an unresolved hard link as unavailable instead of empty", async () => {
|
||||
const directory = await createTestTempDirectory("rea-pkg-hardlink-");
|
||||
const path = join(directory, "Installer.pkg");
|
||||
await writeFile(
|
||||
path,
|
||||
xarArchive([
|
||||
{
|
||||
name: "Payload",
|
||||
data: gzipCpio(
|
||||
[{ name: "./orphan", mode: MODE.file, ino: 3, links: 2 }],
|
||||
"newc",
|
||||
),
|
||||
},
|
||||
]),
|
||||
);
|
||||
const inventory = artifactInventoryResultSchema.parse(
|
||||
parseEvidence(await runProviderAnalysis(path, "inventory_artifact", {}))
|
||||
.normalized_result,
|
||||
);
|
||||
expect(
|
||||
inventory.occurrences.find(
|
||||
({ logical_path: logical }) => logical === "Payload/orphan",
|
||||
),
|
||||
).toMatchObject({
|
||||
artifact_id: null,
|
||||
hash_status: "unavailable",
|
||||
limitations: [expect.stringContaining("Hard-link bytes")],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user