Skip to content

fix(apple): validate build-version tool records within cmdsize - #1784

Merged
N0zoM1z0 merged 1 commit into
mainfrom
fix/1775-macho-build-version-tools
Oct 11, 2026
Merged

N0zoM1z0 merged 1 commit into
mainfrom
fix/1775-macho-build-version-tools

Conversation

@N0zoM1z0

Copy link
Copy Markdown
Collaborator

Summary

Report malformed Mach-O LC_BUILD_VERSION commands when their declared tool records do not fit inside cmdsize. Fixes #1775.

Problem and expected behavior

A 24-byte command with ntools=1 previously produced parsed platform evidence despite having no tool record. The reader must validate the command's complete structure before accepting its platform.

Change and scope

Compare the declared count with the current command body's available 8-byte records, after checking its 24-byte header. This performs no count-driven allocation or iteration. Extra command padding remains accepted; unrelated load-command policies are unchanged.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Mach-O load-command decoding in MachoLoadCommandReader.
  • CLI and MCP/tool-catalog contract: no schema change; trace-dylib-resolution now reports these images as malformed.
  • Provider, bridge, target-format, or platform compatibility: offline Mach-O bytes; valid commands and unknown raw platform values remain supported.
  • Evidence, artifact, provenance, or reconstruction contract: preserve file identity and the parse failure; malformed images have no accepted slices and appear in partial coverage.
  • Process execution, authorization, cleanup, or containment impact: none.
  • Generated metadata, package, or installation impact: none; no generated outputs committed.

Evidence and regression coverage

  • Tests added or updated: one compiled CLI scenario covers valid zero/one records, unknown platform, missing one/two records, maximum u32 count, and a truncated header. A sibling command and image trailer cannot satisfy a missing record.

  • Base reproduction: the added CLI test failed against unchanged production at 0bdc7a40a: expected malformed, received parsed; nine existing CLI tests passed.

  • User-visible output: affected images expose parse_status: "malformed", a reason naming LC_BUILD_VERSION, empty slices, and partial coverage. The CLI can still exit 0 while preserving those failures.

  • Remaining proof gaps: Linux synthetic file workflows; no actual dyld execution or native macOS provider validation.

  • 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

  • npm run test:focused -- src/artifacts/apple/MachoLoadCommandReader.test.ts tests/boundary/cli/dylibResolutionCli.test.ts — reader 24/24 and new CLI regression passed; one pre-existing CLI scenario hit its 30-second timeout.
  • npm run test:focused -- tests/boundary/cli/dylibResolutionCli.test.ts — rerun passed 10/10 without changing timeouts.
  • npm run check — typecheck, lint/module boundaries, formatting, Knip, metadata and architecture guards passed after moving the new test outside the existing describe block to respect its line limit.

Compatibility, safety, and release

  • Breaking changes or migration steps: none; reject malformed input rather than changing valid calls.
  • Real Hopper/Ghidra, browser, or OS coverage: compiled CLI on Linux; native providers/GUI not needed or exercised.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: validate untrusted count against command-local capacity without allocation; preserve caller artifacts.

Review checklist

  • This PR addresses a concrete problem.
  • One focused outcome; Conventional Commit title.
  • Related issue is linked.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs/contracts/generated metadata require no changes.
  • Representative CLI output is described above.
  • Final diff checked for secrets, unrelated cleanup, and unsupported claims.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 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-11T09:43:12.748807Z 6c386d3 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.

@N0zoM1z0 N0zoM1z0 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the command-local bounds check and the compiled CLI regression. The new test fails on the affected base; after the fix it preserves valid/unknown platform evidence and reports missing records as malformed, including sibling-command and maximum-count controls. Reader tests passed 24/24, CLI rerun 10/10 and static checks passed; the initial existing-test timeout is recorded in the PR. Validation is offline Mach-O bytes on Linux, with no dyld/macOS runtime claim. No blocking findings; waiting for current-head CI before merge.

@N0zoM1z0
N0zoM1z0 merged commit 817aef4 into main Oct 11, 2026
31 checks passed
@N0zoM1z0
N0zoM1z0 deleted the fix/1775-macho-build-version-tools branch October 11, 2026 09:50
@github-actions github-actions Bot mentioned this pull request Oct 11, 2026
3 tasks done
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Mach-O LC_BUILD_VERSION accepts tool records outside cmdsize

2 participants