Skip to content

fix(ghidra)!: qualify memory effect coverage - #8651

Merged
morluto merged 12 commits into
mainfrom
codex/ghidra-memory-effect-scope
Nov 8, 2026
Merged

morluto merged 12 commits into
mainfrom
codex/ghidra-memory-effect-scope

Conversation

@morluto

@morluto morluto commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Summary

An empty Ghidra value-flow effects list can omit a direct global read or write. State the actual effect scope in the produced Evidence and advertised schema so an agent does not treat that empty list as proof of no memory access. Related: #8336.

Problem and expected behavior

Ghidra high p-code can represent a direct memory address as an input or output varnode of an operation other than LOAD or STORE. REA's current memory-effect projection only selects those two opcodes. Its previous generic limitations did not explain this exclusion.

Change and scope

The Ghidra producer now includes that scope and suggests recorded instruction references as complementary evidence. The field schema and native investigation guide describe the same boundary. Retained native views already propagate the producer's limitations. trace_native_values now carries each analyzed value-flow source limitation inline with provider/operation attribution and deduplicates repeated caveats. No new effect is inferred and no provider API or execution authority is added.

Contract and boundary impact

  • Owner: Ghidra high-p-code producer; the existing shared view projects the recorded limitations.
  • Contribution scope: existing read-only static analysis; no new scope decision is required.
  • CLI/MCP: new Evidence and composed value traces contain source limitations; the effects output schema has a description. The value-trace workflow profile adds value_flow_limitations: provider-attributed-v1, so older cached results without this policy are not replayed as current. This independent commitment composes with fix(native): retain value trace source evidence #8384's source-ownership revision. Existing historical Evidence is not rewritten.
  • Provider and platform: the Ghidra profile now commits value_flow_effect_scope: pcode-load-store-explicit-v1. Snapshots created before that commitment are refused; analyze without the old snapshot and save a new one. For snapshot-only historical records, the existing manual extraction path is documented; direct snapshot-to-Evidence recovery is tracked separately in [Design] Recover historical Evidence from an incompatible analysis snapshot #8655. Observations remain distinct from instruction references and runtime access.
  • No change to target bytes, selected input, lifecycle, installation, or generated committed artifacts.

Expected effects of verification:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code. (Ghidra's existing headless analysis scripts.)
  • Change process memory, registers, files, or configuration. (Owned temporary Ghidra project and verifier artifacts.)
  • 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 on macOS arm64 through compact and full stdio MCP: a source-owned x86-64 ELF with separate direct global read, direct global write, pointer-parameter read, and immediate-only functions. The first two and the last had no memory effect rows; the indirect read had one memory_read. Every dossier and its retained value_flow_effects view included the scope limitation after this change. Successful results validated against fetched output schemas. Independent disassembly and procedure_references established the direct accesses; the target was not executed and its SHA-256 d3baa5cf385b68e3a8de02ed0884d9c9e781bd2c6b63201250635e4dc37655e8 was unchanged.
  • The same public workflow on baseline ae8223cc failed the scope assertion on the direct-read dossier. The baseline is a separate branch, not this PR's direct parent.
  • Extended the real-Ghidra verifier to check the limitation on both a dossier and its retained effects view. The real lane reached and passed those checks with temporary workarounds for existing verifier failures; it did not pass end to end. Existing blockers are tracked by [Bug] Ghidra verification sends function Evidence beyond the default MCP input allowance #8172 / fix(verification): compare retained Ghidra function evidence #8640, test(ghidra): check structured snapshot profile mismatch #8536, test(ghidra): check regex recovery at its owning boundary #8578, and [Bug] Ghidra snapshot verifier expects retained Evidence to disappear #8380 / test(ghidra): check retained historical snapshot evidence #8381. The temporary workarounds are not in this PR.
  • Real Ghidra trace_native_values on the x86-64 direct-read, indirect-read and immediate-only functions: both compact and full MCP now show the analyze_function provider scope inline; the prior head omitted it while retaining the source dossier ID. Source views and trace responses validated against advertised schemas. A controlled multi-function test verifies attribution and deduplication; a snapshot-cache regression verifies that prior trace Evidence is not replayed under the new commitment.
  • Review follow-up at d2ab1b852: the real-provider verifier now constructs a valid pre-scope snapshot from an actual Ghidra dossier, checks that MCP rejects its old profile without changing the active session or snapshot file, and then checks that a fresh trace retains the scope. This verifier helper passed against real Ghidra 12.1.4 in both MCP profiles on the x86-64 control fixture. The previously recorded real old-snapshot control independently reproduced the original missing-scope failure.
  • Real Ghidra snapshot recovery: before the producer-profile change, a baseline snapshot reopened and the new workflow reran over an old cached dossier without the new limitation; its cited source also hit the separate [Bug] Cached native value traces cite source Evidence absent from exported bundles #8282 ownership issue. With this change, both compact and full MCP profiles rejected the old snapshot with evidence_integrity_mismatch, allowed separately exported historical Evidence to be imported unchanged, and produced the scope on fresh analysis and current-snapshot reopen. Snapshot, bundle and target digests were unchanged. This is one old snapshot and host.
  • Real composed-trace handoff at c103de06f: exported the direct-read trace_native_values and its linked Ghidra dossier, then imported the bundle into a fresh session without an open target in compact and full MCP profiles. The trace record was unchanged, its inline source limitation remained, and the linked retained effects view carried the scope; bundle and target digests were unchanged. Successful replies validated against the advertised schemas. This covers one trace and host.
  • Real target-free handoff: exported one direct-read dossier from baseline ae8223cc and one from this PR, then imported each into fresh MCP sessions in both profiles. The retained effects view preserved the new limitation for the new record and did not invent it for the historical record; both bundle hashes and the target hash remained unchanged. Successful responses validated against advertised schemas. This checks one historical record, not general migration.
  • Combined-branch control: applied this PR over fix(native): retain value trace source evidence #8384 head a20c186e in an isolated checkout and manually preserved fix(native): retain value trace source evidence #8384's value-trace revision 2 after the intermediate cherry-pick removed it. Real Ghidra traces carried the scope and cited retained sources; real Kuna 1.988 partial traces retained resolvable source IDs and the no-def-use unknown, in compact and full profiles. The combined profile contained both revision 2 and value_flow_limitations: provider-attributed-v1. Both standalone branches had independently used revision 2 for different changes; the new separate commitment prevents that collision if the source-ownership revision is preserved during integration. The combined checkout had an older Kuna verified-release policy, so 1.988 was unverified there. This is one fixture and host, not a clean-branch run or broad provider-accuracy claim.
  • No runtime memory access, other architectures, other providers, or autonomous-agent behavior is claimed. This clarifies the current projection; it does not add complete direct-memory effects.

Validation performed

  • Reconciled with main 015a02d5, preserving value-flow scope alongside containing-code identification and refreshing the combined raw-profile digest goldens. Node 24.22.1 focused native-value, analysis-snapshot and Ghidra profile/snapshot suites passed 109 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 value-flow scope and inventory-search projection, and refreshed raw-profile digest goldens for their combined semantics. Node 24.22.1 focused native-value, analysis-snapshot and Ghidra profile/snapshot suites passed 108 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; Node 24.22.1 targeted native-value, analysis-snapshot and Ghidra profile/snapshot suites passed 107 tests. Moved guide formatting and staged diff check passed. Real-provider evidence below predates this integration and was not rerun.

  • Follow-up: merged main ac30fbd, including the style(test): format CLI help default annotations #9280 CLI-help formatting fix; Node 24 npm run format:check passes. The focused tests below ran before this formatting-only main follow-up.

  • Reconciled with main 2e2f981: the workflow profile retains both recorded-versus-unavailable and provider-attributed limitation commitments; source-closure replay tests and both real-verifier helpers are retained. Refreshed raw profile digests for the combined policy. On Node 24.22.1, 107 focused Ghidra snapshot/profile, source-closure, trace and MCP tests passed, as did check:fast, docs:check, changed-file formatting and diff checks. node --check passed for the combined verifier script. Real Ghidra and the full verifier were not rerun after reconciliation; earlier provider evidence below is for the earlier revision. Hosted checks must run on the updated head.

  • Focused real stdio MCP control above: passed in both schema profiles on the changed branch.

  • npm run test:focused -- src/domain/analysisView/analysisView.test.ts tests/boundary/mcp/analyzeFunctionDetail.test.ts — 53 passed.

  • npm run test:focused -- src/application/native/NativeValueTrace.test.ts src/application/binary/AnalysisSnapshotCache.test.ts tests/boundary/mcp/nativeValueTraceCompleteness.test.ts — 77 passed.

  • npm run test:focused -- src/ghidra/GhidraRawProfileDigest.test.ts src/ghidra/GhidraSnapshotCache.test.ts src/ghidra/GhidraProvider.behavior.test.ts src/application/binary/AnalysisSnapshotCache.test.ts — 256 passed after updating profile goldens.

  • npm run check:fast, npm run docs:check, changed-file formatting and git diff --check — passed on the final change.

  • npm run verify:ghidra — failed in existing verifier code as described above; not claimed as passed.

Compatibility, safety, and release

Breaking: an open_binary request that supplies a previously valid Ghidra snapshot without the new effect-scope commitment now returns evidence_integrity_mismatch. Analyze the target without that snapshot and save a fresh one; a separately exported historical Evidence bundle remains importable unchanged. This prevents an old cached dossier from suppressing the limitation in a newly computed trace. Cached value traces without the workflow limitation commitment likewise need fresh analysis. No schema shape or target authority changes. Provider verification is limited to the single host and fixture above.

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 Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The reviewed changes appear safe; no blocking issue remains, and identical changes already exist in local origin/main.

Summary

Qualifies Ghidra memory-effect coverage without adding inferred memory effects.

  • Ghidra explains what its memory-effect rows cover.
  • Value traces keep the caveats from each analyzed function.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Ghidra high p-code] --> B[Function dossier with coverage warning]
  B --> C[Retained effects view]
  B --> D[Value trace]
  D --> E[Attributed and deduplicated caveats]
  F[Producer profile] --> G[Reject old provider snapshots]
  H[Workflow profile] --> I[Skip old cached traces]
Loading

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

@morluto morluto changed the title fix(ghidra): qualify memory effect coverage fix(ghidra)!: qualify memory effect coverage Nov 2, 2026
@morluto
morluto marked this pull request as ready for review November 4, 2026 16:53
@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-08T14:21:47.669246Z 57d883b 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.

@morluto
morluto enabled auto-merge (squash) November 7, 2026 18:18
@morluto
morluto merged commit c5ed046 into main Nov 8, 2026
49 checks passed
@morluto
morluto deleted the codex/ghidra-memory-effect-scope branch November 8, 2026 15:05
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.

1 participant