Skip to content

fix(native): correct Mach-O command completeness - #8937

Draft
ducanhnguyen223 wants to merge 2 commits into
morluto:mainfrom
ducanhnguyen223:codex/fix-8935-macho-completeness
Draft

ducanhnguyen223 wants to merge 2 commits into
morluto:mainfrom
ducanhnguyen223:codex/fix-8935-macho-completeness

Conversation

@ducanhnguyen223

@ducanhnguyen223 ducanhnguyen223 commented Nov 4, 2026 •

Copy link
Copy Markdown

Summary

Fixes #8935.

Problem and expected behavior

Load commands with every payload byte decoded were still reported as partially decoded, which added an incorrect limitation and redundant whole-command digest.

Change and scope

Treat LC_LINKER_OPTION as complete only when the count and NUL-terminated strings exactly consume cmdsize; treat LC_NOTE as complete only at its 40-byte modeled extent and preserve its full owner storage as data_owner_storage_hex; and treat LC_FILESET_ENTRY as complete only when the entry-id starts at byte 32 and its terminator reaches cmdsize. Gaps and extra bytes retain the existing limitation and digest fallback.

This is a focused correction in the existing Mach-O reader. No new capability or target behavior is added; a maintainer scope decision is not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: MachoCommandNames records byte-level completeness; MachoBinaryProjection consumes that fact.
  • CLI and MCP/tool-catalog contract: the evidence projection adds data_owner_storage_hex for all 16 LC_NOTE owner bytes; existing fields retain their meanings.
  • Provider/platform compatibility: general Mach-O parsing; real CLI regression uses macOS Clang.
  • Evidence and provenance: unknown trailing bytes continue to produce the existing limitation and digest.
  • Target interaction: no target is executed; the CLI inspects a local compiler-generated object.
  • Generated metadata/package impact: none.

Expected effect:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Added source regressions for exact and padded commands, an LC_FILESET_ENTRY with an unexamined gap, and an LC_NOTE owner with an embedded NUL followed by nonzero bytes. The gap retains its digest/limitation; the complete owner storage is projected as hex.
  • Added a CLI regression using a real Clang-generated arm64 Mach-O object containing the 16-byte LC_LINKER_OPTION -lz; it verifies the fallback digest and limitation are absent.
  • Remaining proof gap: the full check:pr suite was not run; note/fileset CLI behavior is covered by synthetic binary fixtures, not separate compiler-generated samples.

Validation performed

  • fnm exec --using=24.22.1 npm run test:local -- src/native/MachoCommandNames.test.ts src/native/MachoBinaryProjection.test.ts — 2 files, 20 tests passed.
  • fnm exec --using=24.22.1 npm run test:focused -- tests/boundary/cli/nativeMachoLinkerOptionsCli.test.ts — 1 file, 2 tests passed; included real Clang-generated local input.
  • fnm exec --using=24.22.1 npm run check:fast — typecheck and lint passed.
  • oxfmt --check and git diff --check — passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none; data_owner_storage_hex is additive and all existing evidence fields remain.
  • Real Hopper/Ghidra or other provider coverage: not applicable.
  • Package or release metadata impact: none.
  • Security/privacy: no target execution; only local-format parsing.

Author readiness

Human owner: @ducanhnguyen223

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • Human owner has reviewed the final diff and evidence.
  • Related issue is linked.
  • Tests and generated outputs are current.

@greptile-apps

greptile-apps Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; both previous evidence-loss issues are fixed.

Summary

Corrects when Mach-O commands count as fully decoded.

  • Exact Mach-O command payloads no longer get marked incomplete.
  • Mach-O note results now keep the full owner bytes alongside readable text.

Both previous findings are fixed. No new actionable issues or security issues were found. Tests were inspected but not run during this review. Supersession could not be checked because GitHub access was unavailable.

Reviews (2) · Last reviewed commit: "fix(native): preserve exact Mach-O comma..." · Reviewed by Greptile

Comment thread src/native/MachoCommandNames.ts Resolved
Comment thread src/native/MachoCommandNames.ts Resolved

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] inspect-macho adds an undecoded-payload limitation to fully decoded load commands

1 participant