Skip to content

fix(ghidra): report selected project identity failures - #8379

Merged
morluto merged 3 commits into
mainfrom
codex/ghidra-project-identity-refusal
Nov 4, 2026
Merged

morluto merged 3 commits into
mainfrom
codex/ghidra-project-identity-refusal

Conversation

@morluto

@morluto morluto commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner

Summary

A selected Ghidra project with a missing or different recorded import digest is refused, but REA reports a generic startup failure and suggests rea doctor. Report unavailable identity separately from a known mismatch, while preserving the refusal. Fixes #8169.

Problem and expected behavior

open_binary binds the target lazily; the first Ghidra-backed query starts the bridge. The bridge previously exited before its authenticated connection was ready, so the structured cause was lost. A program whose saved digest is unknown and a program with a different known digest both produced generic doctor advice. Neither case should be admitted; a caller needs the reason and a matching target/project recovery path.

Change and scope

On an identity refusal, roll back the bridge script transaction and serve authenticated failure-only responses until the client closes or sends shutdown. This keeps the producer alive until the refusal can be consumed; all analysis requests remain refused. Tag the two codes as admission errors only when received during startup; a later remote error with the same code remains an operation error. Project the typed cause with selected-project guidance, or provider failure guidance for a fresh import. Do not open an unverified program for analysis or fall back to a fresh import.

This changes an existing read-only admission boundary, not provider or target authority. No additional maintainer scope decision is applicable.

Contract and boundary impact

  • Semantic owner: Ghidra's recorded import digest and the bridge's startup admission check. The authenticated client preserves the producer's two distinct outcomes through the shared error projection.
  • CLI/MCP: existing selected-project queries now return configuration_invalid with identity-specific guidance instead of generic execution_failure; fresh-import failures remain provider failures and do not blame project configuration. No request schema changes.
  • Evidence, target and project: no Evidence is fabricated, no original project or target is modified, and unavailable identity is not a verified mismatch. Existing explicit source-project copying and cleanup remain in force.
  • Provider/platform: applies to the existing Ghidra bridge protocol. Existing-project mode remains POSIX-only; Windows fresh-import and other JDK/Ghidra versions need their own verification.
  • Generated metadata and installation: no generated output is committed and no installation changes.

Expected effects:

  • 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

  • Generated-project public MCP regression on Ghidra 12.1.4 / macOS arm64: a known mismatching import and a deliberately cleared digest produced distinct typed reasons. The matching target reopened successfully on the same MCP connection; both projects and both target files remained unchanged. Public CLI controls returned the same distinct reasons. The regression fails against the pre-change baseline at the mismatched-project assertion.

  • The regression is integrated into the real host-native Ghidra lane. It creates private projects, checks the saved digest-clear operation, verifies the source files and runtime cleanup, and removes its own fixtures. It passed with a short temporary path before rebasing and with a long path on the rebased commit.

  • Real fresh-import failure injection returned the unavailable-identity reason without naming REA_GHIDRA_PROJECT_PATH. This is a controlled bridge injection, not evidence that Ghidra naturally omits a fresh-import digest.

  • Production-client boundary checks exercise both startup codes, Unix socket and authenticated-loopback fixture transports, a same-code error after startup, cleanup failure/retry and cancellation during final cleanup. The loopback fixture is not real Windows verification.

  • Remaining: real Windows and Linux, unauthorized-peer behavior for this failure-only path, malformed/truncated failure frames, multiple waiting callers and other JDK/Ghidra versions have not been independently verified. Existing cleanup ownership and protocol checks remain applicable.

  • Additional restored packed-program control on head 0212145b0: compact and full real Ghidra MCP sessions selected an expanded project previously imported from .gzf. A different target produced the digest-mismatch configuration_invalid refusal; reopening the matching target on the same connection successfully decompiled the expected function. Both target hashes and project-file hashes remained unchanged. This is one macOS arm64 fixture, not a Windows, missing-digest, or cancellation control.

Validation performed

  • Generated-project real-provider regression on the current source — passed for MCP and CLI with a long temporary path after the failure-only shutdown fix; the short-path check passed before rebasing, and the pre-change baseline failed as expected.
  • npm run check:ci:fast, npm run docs:check, npm run verify:ghidra:bridge-sources, npm run test:local -- src/ghidra/GhidraProvider.behavior.test.ts (186 passed), and npm run test:focused -- tests/boundary/providers/ghidra/ghidraClient.test.ts (100 passed) — all passed after the shutdown fix.
  • Full host-native npm run verify:ghidra passed on rebased 34670812 in an isolated checkout with two verifier-only corrections: retained-Evidence references for [Bug] Ghidra verification sends function Evidence beyond the default MCP input allowance #8172 and the snapshot-history correction tracked in [Bug] Ghidra snapshot verifier expects retained Evidence to disappear #8380 / PR test(ghidra): check retained historical snapshot evidence #8381. Ghidra 12.1.4 reported 433 successful and 52 rejected boundary calls, the new project identity checks, complete cleanup and an empty verified descendant list. This was before the subsequent shutdown-race fix and is not a clean-tree or final-head lane pass. The final shutdown behavior was checked through the targeted real-provider regression and client boundary tests above.

After merging main through 46c13b998 (head 0212145b0), the 196 Ghidra provider and 100 Ghidra client boundary tests passed, npm run check:fast passed, and npm run verify:ghidra:bridge-sources compiled against Ghidra 12.1.4/JDK 21. The generated-project identity verifier passed on macOS arm64 through CLI and MCP: distinct mismatch/unavailable refusals, matching-target recovery, and unchanged source files. On this head, npm run verify:ghidra failed at compare_functions before schema validation: the verifier sent inline Evidence exceeding the default 1,024-element MCP input allowance (#8172; fix proposed in #8541). It did not complete the full lane. A process-list check afterward found no matching Ghidra headless or verifier process; this is not a complete process-family ownership audit.

A separate controlled real-Ghidra MCP run at 0212145b0 replaced the bridge in a temporary checkout with a script that throws an unrelated exception. Ghidra exited zero after logging the script error; REA returned a generic execution_failure, retained the diagnostic, did not label it as either identity refusal, and cleaned the runtime. The target remained unchanged. This is an injected fault, not a naturally observed installation failure.

A separate temporary integration checkout at head 0212145b0 with verifier-only changes from #8541, #8381, #8536 and #8578 passed npm run verify:ghidra on macOS arm64, Ghidra 12.1.4 and JDK 21. It reported 439 successful and 52 rejected boundary calls, verified process lineage and no remaining descendants. This is a combined run, not a clean-tree pass of #8379 alone. The first combined attempt without #8536 stopped at the old profile-mismatch wording; the second without #8578 stopped at the old regex-retention assertion.

Compatibility, safety, and release

  • Existing identity refusals become actionable errors; successful analysis, snapshot and Evidence semantics are unchanged. No compatibility shim or target execution is introduced.
  • Real-provider verification: Ghidra 12.1.4 and JDK 21 on macOS arm64. The test fixture's cleared digest is synthetic; other platforms, Ghidra versions and JDKs are unverified.
  • No new persisted user configuration, package installation, target mutation or project editing is introduced. The failure-only server remains on the existing authenticated local transport.

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.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@greptile-apps

greptile-apps Bot commented Oct 31, 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

This PR distinguishes unavailable Ghidra import identity from a known digest mismatch without admitting either program.

  • Ghidra reports why a selected program's import identity cannot be verified.

Diagram

sequenceDiagram
    participant Client as REA client
    participant Bridge as Ghidra bridge
    Bridge->>Bridge: Check recorded import digest
    alt Digest unavailable or different
        Bridge->>Bridge: Roll back script transaction
        Client->>Bridge: Authenticated ping
        Bridge-->>Client: Distinct identity refusal
        Note over Bridge: Refuse all analysis requests
        Client->>Bridge: Authenticated shutdown
        Bridge-->>Client: Shutdown acknowledgement
        Client->>Client: Stop owned process and remove runtime
    else Digest matches
        Bridge->>Bridge: Initialize analysis services
        Client->>Bridge: Authenticated ping
        Bridge-->>Client: Session identity
    end
Loading

Reviews (3) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

Comment thread bridge/ghidra/ReaGhidraBridge.java Resolved
@morluto
morluto marked this pull request as ready for review November 1, 2026 03:55
@chatgpt-codex-connector

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

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T17:29:32.882524Z 0212145 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.

…identity-refusal

# Conflicts:
#	src/ghidra/GhidraProvider.behavior.test.ts
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] Ghidra project digest mismatch is hidden behind generic provider startup failure

1 participant