Skip to content

fix(ghidra)!: distinguish skipped overlays in byte search - #8608

Merged
morluto merged 12 commits into
mainfrom
codex/byte-search-overlay-coverage
Nov 8, 2026
Merged

morluto merged 12 commits into
mainfrom
codex/byte-search-overlay-coverage

Conversation

@morluto

@morluto morluto commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

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 though inspect_native_load_image reported loaded: 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_loaded and loaded overlays in searched.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 what complete means. The Ghidra profile commits to the changed search-coverage semantics.

Contract and boundary impact

  • Semantic owner: the Ghidra memory-block producer classifies the exclusion; the shared byte-search result validates and transports it.
  • Contribution scope: existing static analysis and session behavior; no new execution or mutation capability, so no new maintainer scope decision applies.
  • CLI/MCP: search_bytes results require searched.skipped_overlays; loaded overlays move out of skipped_not_loaded. Refresh cached MCP schemas and update strict clients to use the new field.
  • Evidence and snapshots: new results carry a revised Ghidra analysis profile. Existing profile-bound Ghidra snapshots are refused rather than replaying the old representation; previously exported Evidence remains importable as historical data.
  • Target selection, authority, cleanup, installation and package effects are unchanged.

Expected effects of the verified existing workflow:

  • 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

  • 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_0 under skipped_overlays; an unloaded _elfHeader overlay appears only under skipped_not_loaded. A search bounded to segment_0 finds the expected bytes at segment_0:0x401000 and file offset 0x1000. 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 a67525cd after 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 checks failed on main's pre-existing formatting in cliHelpDefaultAnnotations.test.ts; merged main ac30fbd6 (which fixes it) into this branch. On Node 24.22.1, the full format: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, bytePattern and toolEffects. Profile digest goldens now commit to both the overlay and current bit-field semantics; admission tests cover both policy changes. Changed conflict files passed oxfmt --check, and git diff --cached --check passed.

  • 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:raw with 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:raw with 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-file oxfmt --check, and git 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 start address 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.ts passed 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.ts because 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_overlays is required in new search results, and loaded overlays no longer occur in searched.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:

  • 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.

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.
@greptile-apps

greptile-apps Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge; no new actionable issue was found.

Summary

Separates loaded overlays from unloaded blocks in Ghidra byte-search coverage without changing which blocks are searched.

  • Unbounded Ghidra searches list loaded overlays separately.

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"]
Loading

Reviews (10) · Last reviewed commit: "fix(ghidra): preserve overlay and contai..." · Reviewed by Greptile

Comment thread scripts/verify-real-ghidra-raw.mjs Resolved
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-08T00:53:58.271549Z a47578b New commits
ℹ️ 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.

Keep contiguous initialized-block search and list loaded overlays in
skipped_overlays. Unloaded blocks, including unloaded overlays, stay in
skipped_not_loaded.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Comment thread docs/testing-lanes.md Resolved
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.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@morluto
morluto enabled auto-merge (squash) November 7, 2026 18:18
@morluto
morluto merged commit 887b998 into main Nov 8, 2026
49 of 51 checks passed
@morluto
morluto deleted the codex/byte-search-overlay-coverage branch November 8, 2026 01:50
Entrpi added a commit to Entrpi/rea that referenced this pull request Nov 8, 2026
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.
Entrpi added a commit to Entrpi/rea that referenced this pull request Nov 8, 2026
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).
@morluto morluto added bug Something isn't working provider: ghidra Analysis provider / engine: ghidra labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working provider: ghidra Analysis provider / engine: ghidra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Byte search labels loaded overlays as not loaded

2 participants