Repository navigation
fix(ida): thin the selected FAT slice into the private headless input - #2201
Merged
Merged
Conversation
Universal Mach-O admission reported the selected slice architecture while the IDA provider's private input copy handed the whole FAT container to upstream idalib, which then picked its own slice (x86_64 for /bin/cat) while Evidence labeled the session arm64. FAT parsing now exports the selected slice's byte range as universalSlice, and the private input copy writes exactly those bytes: the whole source digest still anchors the copy against admission-time changes, and the thinned result anchors the post-operation identity check. Thin targets keep the whole-file copy, and mach-o-universal remains the container format across Evidence, snapshots, and provider routing. Validation: typecheck, oxlint (no new warnings), oxfmt, and targeted vitest runs — ida adapters 12 files/116 tests, domain and services projects 60 files/736 tests, ghidra/hopper behavior 2 files/50 tests, filesystem and universal-extraction boundary 2 files/49 tests, native signature MCP 1 file/2 tests, plus a new thinning suite (5 tests, red before the fix: 3 failed). The thinned product was verified byte-identical to the `clang -arch arm64` input of a `lipo -create` universal fixture. Controlled fixtures only; no live IDA analysis was performed for this change. Closes morluto#2139
Closed
2 tasks done
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
3 tasks done
13 of 19 tasks
15 of 22 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Universal Mach-O admission resolved and reported the host-preferred slice's architecture, but the IDA provider's private input copy handed the whole FAT container to upstream idalib, which then picked its own slice (x86_64 for
/bin/cat) while Evidence labeled the session arm64. FAT parsing now exports the selected slice's byte range asuniversalSlice, and the private input copy writes exactly those bytes.Fixes #2139
Problem and expected behavior
On an arm64 macOS host with the IDA provider (headless
idalib-mcp), opening a universal binary reportsarchitecture: "arm64"inopen_binary, every Evidence subject, and the analysis profile, while the analysed code is the x86_64 slice (push rbp; mov rbp, rspSysV prologue onstart). The violated invariant: the architecture recorded in Evidence must describe the bytes the provider actually analyses.Root cause, read from
srcat the base of this branch:parseFatMachO(src/domain/binaryTarget.ts:103;:113-:159at base5190843f8) already resolved the host-compatible preferred slice and computed its byte range, but the resolved target kept the whole FAT path with no slice offset/size exported.BinaryTargetResolver.ts:70usesprocess.archonly for the reported architecture; the resolvedpathstays the whole container.IdaWorkspace.copyInput(src/ida/IdaWorkspace.ts:64) copied the whole FAT into the private workspace, so upstream idalib chose its own slice.Change and scope
BinaryTarget'smach-o-universalvariant now carry a requireduniversalSlice { offset, size }(src/domain/binaryTargetTypes.ts:34,src/domain/binaryTarget.ts:174). Container-identity semantics are unchanged:mach-o-universalremains the container format across Evidence, snapshots, and provider routing, andsha256stays the whole-file digest.copyInputbecame a single-pass bounded streaming copy (64 KB chunks): the whole-file sha256 still anchors the copy against admission-time source changes, but only the selected slice's bytes are written, and the digest of the thinned product is exposed asinputSha256(src/ida/IdaWorkspace.ts:38).IdaSessionClient.ts:510accordingly anchors the thinned product instead of the whole container.Contract and boundary impact
mach-o-universaltargets is now the selected slice, so upstream idalib can no longer pick a different slice than the reported architecture. Other providers and thin formats are untouched.Evidence and regression coverage
Tests added:
src/ida/IdaWorkspaceThinning.test.ts(5 tests: arm64 slice thinning, x86_64 slice when the host is intel, whole-file copy for thin targets, rejection of a universal source changed after admission, headless session bound to the thinned input identity).analysisSnapshotandbinaryTargetTypesfixtures updated for the requireduniversalSlice.Base reproduction (executed): on clean
origin/main58fb37207(this branch's rebased parent) the new suite fails 3 failed | 2 passed (5) — the two thinning tests and the whole-file-copy test fail (src/ida/IdaWorkspaceThinning.test.ts:48,:74,:91: the copied input is the whole FAT, not the 32-byte slice, andinputSha256isundefined) — and passes with this change.Remaining proof gaps: no live IDA analysis (unlicensed here); universal-slice behavior verified with synthetic
lipofixtures, not real-IDA sessions.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
npx vitest run --project adapters src/ida/IdaWorkspaceThinning.test.ts— 5 passed (5) with the change; 3 failed | 2 passed on cleanorigin/main58fb37207(base reproduction above)npx vitest run --project adapters src/ida/— 12 files, 116 passednpx vitest run --project domain --project services— 201 files, 2854 passed, 3 skipped (full projects after rebasing onto58fb37207)npx vitest run --project adapters src/ghidra/GhidraProvider.behavior.test.ts src/hopper/HopperAnalysisProfile.test.ts— 2 files, 50 passednpx vitest run --project boundary tests/boundary/filesystem/binaryTarget.test.ts tests/boundary/providers/native/artifactProvider.universalExtraction.test.ts— 2 files, 49 passednpx vitest run --project mcp-boundary tests/boundary/mcp/nativeSignatureTargetBindingMcp.test.ts— 1 file, 2 passednpx oxfmt .(no-op; tree unchanged) thennpx vitest run src/ida/ src/domain/binaryTarget.test.ts— 13 files, 151 passednpx vitest run src/ida/IdaWorkspaceThinning.test.ts src/ida/IdaWorkspaceOwnership.test.ts src/ida/IdaSessionClient.test.ts— 3 files, 45 passednpx tsc --noEmit— cleannpx oxlint— 866 warnings and 0 errors, identical multiset to a cleanorigin/main58fb37207worktree (verified by diffing normalized warning triples; the only differences are two pre-existing warnings whose line numbers shifted inside edited files — zero new)npx oxfmt --checkon the 9 changed files — all passnpx knip— 1 unresolved import (#javascript-analysis-worker), identical on cleanorigin/main(pre-existing)clang -arch arm64/-arch x86_64+lipo -createbuilt a real 33224-byte universal (x86_64@4096+4272, arm64@16384+16840); thecopyInputproduct was byte-identical to theclang -arch arm64original, LE magic0xfeedfacf, cputype0x0100000c, length =universalSlice.size= 16840Compatibility, safety, and release
Review checklist
type(scope): outcome.🤖 Generated with Claude Code