Commit Graph
6 Commits
Author SHA1 Message Date
morluto f1f0a986fd fix(artifacts): enforce archive-wide limits and unambiguous xar metadata 2026-10-08 23:16:28 +08:00
morluto 9b38f3a0af fix(artifacts): preserve unavailable members and stored checksum evidence 2026-10-08 17:08:17 +08:00
morluto 116d722339 fix(artifacts): harden pkg readers for hostile packages and integrity policy 2026-10-08 15:33:35 +08:00
Kaoru0822andClaude Opus 5.5 7857d2d329 fix(artifacts): apply the integrity policy to xar checksums and bound symlinks
- Inventory scans now verify xar extracted checksums themselves, under the
  caller's integrity policy. Under "fail" a mismatch still fails, now as
  artifact_integrity_mismatch with the logical path. Under
  "record-and-continue" the member stays in the graph as mismatched, with
  the declared and observed values, and is not expanded. A declared SHA-256
  becomes an integrity contradiction. Extraction keeps verifying in the reader.
- Read cpio symlink targets only up to 4096 bytes; longer declared targets
  are streamed past and recorded with a limitation instead of buffered.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 12:50:52 +00:00
Kaoru0822andClaude Opus 5.5 daf504b62f 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>
2026-10-07 12:03:28 +00:00
Kaoru0822andClaude Opus 5.5 54dd1a7604 feat(artifacts): inventory flat installer packages
A .pkg inventory recorded only the root hash. Flat installer packages
are xar archives, and their install scripts and payloads are what an
analyst needs to review.

A pure TypeScript xar reader, which also runs off macOS:
- reads the TOC (zlib XML) and verifies the TOC checksum;
- walks nested product-package members, such as Component.pkg/;
- decodes raw and zlib ("x-gzip") members, verifying each extracted
  SHA-1/MD5 checksum as the bytes stream;
- rejects unsafe member names.

Gzip-cpio Scripts and Payload members are expanded as nested containers
by a streaming odc/newc cpio reader. It reads members once, in archive
order, and holds at most one chunk. pbzx (xz) payloads are recorded
with a limitation that names pkgutil --expand-full. Unsupported member
encodings, traversal, and truncation fail with typed reasons.

@xmldom/xmldom (already installed through plist) becomes a direct,
pinned dependency for TOC parsing.

verify:installer-package builds component, product, and pbzx packages
with pkgbuild and productbuild. It checks the expanded Payload against
`pkgutil --payload-files`, script and payload content digests, product
nesting, and CLI/MCP parity, and runs in the macOS CI job.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 11:28:34 +00:00