Repository navigation
fix(ghidra)!: distinguish skipped overlays in byte search - #8608
Conversation
BREAKING CHANGE: Byte search results require skipped_overlays; loaded overlays no longer appear in skipped_not_loaded. The Ghidra profile changes so prior snapshots are not replayed.
[Medium impact] The PR appears safe to merge; no new actionable issue was found. SummarySeparates loaded overlays from unloaded blocks in Ghidra byte-search coverage without changing which blocks are searched.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Memory block"] --> B{"Address bound supplied?"}
B -->|Yes| C["Select its address space and clip range"]
B -->|No| D{"Loaded?"}
D -->|No| E["skipped_not_loaded"]
D -->|Yes| F{"Overlay?"}
F -->|Yes| G["skipped_overlays"]
F -->|No| H{"Initialized?"}
C --> H
H -->|No| I["skipped_uninitialized"]
H -->|Yes| J["Search eligible bytes"]
Reviews (10) · Last reviewed commit: "fix(ghidra): preserve overlay and contai..." · Reviewed by Greptile |
Codex Review Summary: ✅ CompletedThis 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. |
Keep contiguous initialized-block search and list loaded overlays in skipped_overlays. Unloaded blocks, including unloaded overlays, stay in skipped_not_loaded.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
The raw Ghidra lane checks a manually created overlay block through MCP. Say that, and do not claim an overlapping-load ELF, CLI search, or snapshot cursor handoff.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
targetDiagnostics.test.ts: main checks the load remediation's arguments by pattern instead of a frozen sentence; check the branch's added arguments the same way with stating(). Main's instruction-status (morluto#8777), byte-search coverage (morluto#8608) and value-flow (morluto#8651) revisions change every Ghidra raw profile digest. The legacy pins take the digests main computes at 5044e20 for the same loads, the M-profile pin is recomputed, and rawLoadCompatibility.test.ts sets aside the new revisions.
Main's instruction-status (morluto#8777), byte-search coverage (morluto#8608) and value-flow (morluto#8651) revisions change every Ghidra profile. Control: with main's GhidraAnalysisProfile.ts changes since 99db80a reversed, the old pins hold (169 of 171; the other two assert the new parameters).
Summary
A default Ghidra byte search can skip a loaded overlay, but reported it as
skipped_not_loaded. Separate the exclusion reasons and tell callers how to search the overlay. Fixes #8607.Problem and expected behavior
On a source-generated ELF with overlapping load segments, Ghidra loads the displaced segment as an initialized overlay. An unbounded search for its bytes returns no match and
complete: true; the overlay was listed as not loaded even thoughinspect_native_load_imagereportedloaded: true. Search completeness is limited to eligible blocks, and its skipped-region labels must preserve why a block was excluded.Change and scope
The Ghidra bridge now puts unloaded blocks in
searched.skipped_not_loadedand loaded overlays insearched.skipped_overlays. A block that is both unloaded and an overlay appears once as unloaded. Explicit bounds selecting an address space retain the existing behavior. The CLI help, MCP tool and output descriptions explain that unbounded searches skip these blocks, how to select an overlay, and whatcompletemeans. The Ghidra profile commits to the changed search-coverage semantics.Contract and boundary impact
search_bytesresults requiresearched.skipped_overlays; loaded overlays move out ofskipped_not_loaded. Refresh cached MCP schemas and update strict clients to use the new field.Expected effects of the verified existing workflow:
Evidence and regression coverage
Real Ghidra 12.1.4/JDK 21, macOS arm64: the generated ELF has two file-backed load segments at the same numeric virtual address. The unbounded search reports loaded
segment_0underskipped_overlays; an unloaded_elfHeaderoverlay appears only underskipped_not_loaded. A search bounded tosegment_0finds the expected bytes atsegment_0:0x401000and file offset0x1000. A 16-match overlay search was paged in six pages, with its cursor resumed after snapshot reopen; both start-only and end-only bounds select the overlay. A cursor used with a different pattern is rejected as invalid_request. A separate-process MCP control exercised the handoff in compact and full profiles. The result and Evidence ID survive snapshot reopen; source bytes are unchanged. Search responses were validated against their advertised schemas.The same real-provider regression on the pre-change base fails because the new overlay category is absent; the original result placed the loaded overlay under
skipped_not_loaded.MCP boundary checks preserve both categories and reject malformed overlay ranges. Snapshot admission rejects the older profile; raw-profile digest goldens commit to the new policy.
A previously exported real byte-search record was imported into a fresh target-free MCP session and returned with its original pre-change result shape.
The real CLI default and bounded searches matched the corresponding MCP results (compact-profile verifier run). CLI help was inspected separately; the verifier does not freeze its wording.
Remaining gaps: no Windows or Linux real-provider run for the new control; no autonomous-agent behavior or general ELF/runtime loader claim.
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
Reconciled with main
015a02d5, preserving loaded-overlay search scope alongside containing-code identification and refreshing the combined raw-profile digest goldens. Node 24.22.1 focused byte-pattern, Ghidra inventory/profile/snapshot and tool-effects suites passed 100 tests; digest formatting and staged diff checks passed. Real Ghidra verification was not rerun after this reconciliation; earlier provider evidence predates it.Reconciled with main
f912a684: retained separate snapshot admission coverage for loaded-overlay search scope and inventory-search projection, and refreshed raw-profile digest goldens for their combined semantics. Node 24.22.1 focused byte-pattern, Ghidra inventory/profile/snapshot and tool-effects suites passed 99 tests; changed conflict files passed formatting and staged diff checks. Real-provider evidence below predates this integration and was not rerun.Reconciled with main
a67525cdafter the documentation move, preserving the overlay lane and updating its moved raw-binary guide link. Node 24.22.1 targeted byte-pattern, Ghidra inventory/profile/snapshot and tool-effects suites passed 98 tests; moved documentation formatting and staged diff check passed. Real-provider evidence below predates this integration and was not rerun.CI follow-up:
Static checksfailed on main's pre-existing formatting incliHelpDefaultAnnotations.test.ts; merged mainac30fbd6(which fixes it) into this branch. On Node 24.22.1, the fullformat:check, staged diff check and 98 focused tests passed after the merge. Hosted CI was restarted on the new head.After reconciling with main
0ecf3a4c, five focused source suites passed 98 tests on Node 24.22.1:GhidraRawProfileDigest,GhidraSnapshotCache,GhidraInventoryValues,bytePatternandtoolEffects. Profile digest goldens now commit to both the overlay and current bit-field semantics; admission tests cover both policy changes. Changed conflict files passedoxfmt --check, andgit diff --cached --checkpassed.The real Ghidra results below predate this integration; they were not rerun on the merged head.
npm run test:focused -- src/domain/native/bytePattern.test.ts src/ghidra/GhidraInventoryValues.test.ts src/ghidra/GhidraSnapshotCache.test.ts src/ghidra/GhidraRawProfileDigest.test.ts tests/boundary/mcp/ghidraInventoryMcp.test.ts tests/boundary/mcp/officialArguments.test.ts— 96 passed.npm run verify:ghidra:rawwith real Ghidra and JDK, once per compact and full MCP schema profile — passed the raw lane and added overlay/snapshot control, with verified process lineage and cleanup.The added real-provider control against pre-change
d3ab0faf5— failed at the missing overlay category, as expected.npm run test:focused -- tests/boundary/cli/searchBytesAdmission.test.ts— 7 passed.After the CLI follow-up,
npm run verify:ghidra:rawwith compact MCP schemas — passed, including the actual CLI searches. The brittle help-text assertions were subsequently removed; the compact real-provider lane passed again.npm run check:fast,npm run docs:check, changed-fileoxfmt --check, andgit diff --check— passed.The previous GitHub Actions static job failed formatting on 16 unchanged base files; draft fix(test): restore the two checks #8573 left red on main #8592 addresses that baseline. The affected run also failed formatting on those unchanged base files; a fresh run will check the updated head.
The subsequent GitHub source suite exposed a test classification failure: the public description names the
startaddress bound, which the effect-wording heuristic interpreted as process launch. The existing exception table now identifies that parameter as a bound;npm run test:local -- src/contracts/toolEffects.test.tspassed all 8 tests. This does not change tool effects or runtime behavior.The same CI run failed four Frida verifier cleanup cases in shard 4, previously reproduced on the unchanged base and addressed by draft fix(test): load real Frida verifier address dependency #8596. A fresh run is pending.
A later CI run failed shard 7 in
javascriptRuntimeObservationMcp.test.tsbecause its independent direct observation returned an error; the log does not include the underlying error. This test is outside the changed files, but its cause has not been established. Static formatting also failed on the previously recorded baseline files.Compatibility, safety, and release
Breaking:
searched.skipped_overlaysis required in new search results, and loaded overlays no longer occur insearched.skipped_not_loaded. Clients should refresh their schema and read the new list. Ghidra snapshots created with the prior profile are not replayed. Historical Evidence remains importable without being rewritten. The tested target was analyzed statically and not executed.Author readiness
Human owner: