Skip to content

fix(artifacts): compare package signatures without ASCII folding - #2069

Merged
morluto merged 1 commit into
morluto:mainfrom
1052326311:fix/package-magic-bytes
Oct 12, 2026
Merged

morluto merged 1 commit into
morluto:mainfrom
1052326311:fix/package-magic-bytes

Conversation

@1052326311

Copy link
Copy Markdown
Contributor

Summary

Reject high-bit aliases of PKG/DMG signatures at artifact inventory and binary-target admission. Node's Buffer.toString("ascii") clears bit 7: f8 61 72 21 decodes as xar!, and eb 6f 6c 79 as koly. These are not the format signatures but currently select the package routes.

Problem and expected behavior

A .pkg with the former four bytes is reported as PKG; a 512-byte .dmg with the latter at its trailer is reported as DMG. Classification must compare the observed bytes exactly. Found while inspecting the admission boundary; no separate issue exists.

Change and scope

Replace the four lossy string comparisons with exact buffer equality in the two existing admission paths. Keep their suffix, read-length, and trailer-location requirements. No package decoder or execution path is added.

Contract and boundary impact

  • Semantic owner and earliest changed stage: artifact format recognition in inventory and BinaryTargetResolver.
  • CLI and MCP/tool-catalog contract: malformed high-bit aliases stop selecting PKG/DMG; schemas unchanged.
  • Provider, bridge, target-format, or platform compatibility: exact valid signatures retain their existing classification; no bridge changes.
  • Evidence, artifact, provenance, or reconstruction contract: classification follows observed bytes, with no hash/provenance changes.
  • Process execution, authorization, cleanup, or containment impact: none.
  • Generated metadata, package, or installation impact: none.

Evidence and regression coverage

Real filesystem fixtures cover valid signatures plus an independent bit-7 mutation of each signature byte through both classifyAndHashRoot and parseBinaryTarget. Base 3bdc8730 fails both new cases (12 existing pass); the fix passes all 14. Current upstream 4573e8cf changes neither owner.

This validates static admission, not complete XAR/UDIF validity or native package mounting. No real Hopper/Ghidra/browser verification is applicable.

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

Node 24.18.0 / npm 11.16.0, macOS arm64:

  • npm run test:focused -- tests/boundary/filesystem/zipDetection.test.ts — 14 passed; includes build preparation.
  • npm run check — passed, lint warnings and zero errors.
  • npm run docs:check — passed.
  • Pre-push check:fast and git diff --check — passed.

Compatibility, safety, and release

No breaking API, migration, package metadata, or authority changes. Invalid files may now yield the ordinary file classification or a BinaryTargetError instead of a false package format. Full suite and native mounting were not run.

Review checklist

  • Concrete bug, focused conventional title, no separate issue as explained above.
  • Regression covers both affected consumers and valid controls.
  • Metadata checks pass; no generated files committed.
  • Final diff checked for secrets, unrelated changes, and unsupported claims.

AI-assisted with Codex.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T06:16:36.571162Z b8a4379 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@morluto
morluto merged commit 75a4a14 into morluto:main Oct 12, 2026
2 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 12, 2026
3 tasks done
@morluto morluto added bug Something isn't working area: evidence Evidence, artifacts, and reconstruction labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: evidence Evidence, artifacts, and reconstruction bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants