Repository navigation
feat(native): admit raw binaries with caller-supplied architecture and entry - #1868
Conversation
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 04cbf4d394
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 90da1cec77
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summary
Callers can now open a headerless executable by supplying the CPU family and the address where file offset 0 is mapped. Header-based detection is unchanged when
formatis omitted. Hopper and IDA refuse this interpretation; Ghidra imports it withBinaryLoaderand a little-endian generic language, then seeds anentryfunction before auto-analysis.Fixes #1836
Demo
Problem and expected behavior
A local image without ELF, Mach-O, PE, or MZ headers is rejected as
truncated or unsupported binary header. Embedded firmware often has those headers removed, so inventory and function analysis cannot start even when the caller already knows the CPU family and load address.format=raw-binarywitharchitecture(x86,x86_64,arm, orarm64) andentry_point(0xhex) admits the complete file as an executable. File offset 0 maps at that address. Architecture or entry withoutformat=raw-binaryis rejected. The analysis profile includes the bound Ghidra language and canonical entry, so a different architecture or entry is a different snapshot identity.Change and scope
New domain admission (
src/domain/rawBinary.ts) composed throughparseBinaryTarget, session open, and shared CLI/MCP adapters:open_binaryremains a singletype: objectinput. Pairing is enforced withsuperRefine, not an inputanyOf.--target-format raw-binary --architecture … --entry-point …on native inspect, function, and load-image commands.BinaryLoader,language_selection: caller-supplied-v1, canonicalentry_point,load_image_evidence: independent-raw-mapping-context-v1. Languages:x86:LE:32:default,x86:LE:64:default,ARM:LE:32:v7,AARCH64:LE:64:v8A.ReaGhidraPrepareRaw.javamaps file offset 0 at the entry, thenaddEntryPoint/disassemble/createFunction("entry")before auto-analysis.target_format_unsupportedwith a Ghidra-directed reason. Windows Ghidra P0 remains PE-only (applications and DLLs)..agents/skills/reverse-engineer-anything/(skill version 39). Catalog regenerated; build outputs not committed.Out of scope: a load address independent of entry, big-endian / Thumb-only / Cortex-M / PowerPC languages, analyzer overrides, guessing vector tables or memory maps, and a new MCP tool.
Contract and boundary impact
src/domain/rawBinary.ts, thenparseBinaryTarget/ session open, CLI/MCP adapters, GhidraBinaryLoader+ prepare script.open_binarygains optionalarchitectureandentry_point;formatenum addsraw-binary. CLI--architectureand--entry-pointjoin--target-format. Output format enums and native load-image results add araw-binaryverified/mismatch variant. Input schema stays a single object.bridge/ghidra/ReaGhidraPrepareRaw.java.entryPointSourceand does not change the digest. Load-image checks keep observed vs expected facts distinct.docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs andskills/; edit authored instructions in.agents/skills/reverse-engineer-anything/and never commit build outputs): skill version 39 in.agents/skills/reverse-engineer-anything/andsrc/generatedPackageMetadata.ts;package.jsonfiles list includesReaGhidraPrepareRaw.java.Evidence and regression coverage
open_binaryinput contract; filesystem target resolution including misleading suffixes; Ghidra language map, profile digest, Windows P0 refusal, launcher argv, and load-image attestation; Hopper/IDAtarget_format_unsupported; CLI inspect before/missing-flags/Hopper-refusal; MCP open success and omitted architecture.58767790,rea inspectof a four-byte headerless image reportstruncated or unsupported binary header;--target-format raw-binaryis not a format hint until architecture and entry are also supplied.ecu.bin(1eff2fe1). Inspect without flags:target_unavailable/truncated or unsupported binary header.--target-format raw-binaryalone:raw-binary format requires architecture (x86, x86_64, arm, or arm64). Full flags with--provider hopper:capability_unavailable/target_format_unsupported(“Headerless raw-binary analysis requires the Ghidra adapter with a caller-supplied architecture and entry point.”), notunsupported binary format. Architecture without format:architecture and entry_point apply only with format=raw-binary. MCPopen_binarywithformat,architecture, andentry_pointreturnsformat: "raw-binary".verify:ghidra:rawlane in this increment.For evidence-bearing changes:
Validation performed
npm ci— pass (377 packages added, 378 audited)npm run test:focused -- src/domain/rawBinary.test.ts src/contracts/sessionLifecycleInputs.test.ts src/ghidra/GhidraRawBinaryLoadImage.test.ts src/ghidra/GhidraProvider.behavior.test.ts src/hopper/HopperProvider.test.ts src/ida/IdaProvider.test.ts tests/boundary/cli/rawBinaryCli.test.ts tests/boundary/mcp/rawBinaryMcp.test.ts tests/boundary/filesystem/rawBinaryTarget.test.ts tests/boundary/providers/ghidra/ghidraLauncher.test.ts tests/boundary/providers/hopper/hopperAnalysisProfile.test.ts— pass (11 files, 98 passed, 1 skipped)npm run check:fast— passnpm run check— pass (typecheck, lint, format, knip, metadata:check; 6/6 turbo tasks; architecture-guards)npm run docs:check— passnpm run verify:test-discovery— pass (“Discovered all 843 test files exactly once.”)Compatibility, safety, and release
format=raw-binaryplus optional architecture/entry. Omittedformatstill uses header-based detection. Existingdos-comand headered targets are unchanged.bridge/ghidra/ReaGhidraPrepareRaw.java.Review checklist
type(scope): outcome.