Skip to content

docs(native): clarify memory and file byte sources - #8829

Merged
morluto merged 2 commits into
mainfrom
codex/ghidra-byte-source-contract
Nov 4, 2026
Merged

morluto merged 2 commits into
mainfrom
codex/ghidra-byte-source-contract

Conversation

@morluto

@morluto morluto commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Summary

Ghidra's read_bytes can return initialized memory bytes that include loader fixups that differ from the original file at the offset reported by address_to_file_offset. Make that distinction visible in both MCP tool descriptions and CLI help. Related: #8170 and #8556.

Problem and expected behavior

The existing Evidence limitation explains loader fixups after a read, but the catalog descriptions do not explain the distinction when the caller chooses a tool. An offset maps one address; it does not establish a contiguous file range or byte equality with modeled memory.

Change and scope

Clarify the existing contracts only. This changes no result, provider operation, target access, or schema. Contribution scope decision: not applicable; documentation of existing static behavior.

Contract and boundary impact

  • Semantic owner: Ghidra's memory and source-byte mapping remain the producers; the CLI and MCP descriptions explain their existing observations.
  • Provider compatibility: the loader-fixup statement is explicitly Ghidra-specific; the offset caveat applies to a single-address mapping.
  • Evidence, target authority, cleanup and installation: unchanged. No generated artifacts committed.
  • Documentation or usability only; no target interaction.

Evidence and regression coverage

Real Ghidra 12.1.4 on macOS arm64, through compact and full stdio MCP, read c003000001000000 at 0x100004000 and mapped that address to file offset 16384; an independent read of the target file at that offset gave c003000000000000. The fixture SHA-256 was 496e188170232c15f1ceeebf33165f060c6a31b46be9571b6f49778ef0e8d910 and remained unchanged. Both catalogs exposed the new descriptions. No output schemas or runtime behavior changed, and no new test was added for this wording-only clarification. One host and fixture; no autonomous-agent trial or general claim about all fixups.

A second control at the fixture’s code address 0x1000003c0 returned the same eight bytes (ff4300d1e00f00b9) from Ghidra memory and the mapped file offset 960, in both profiles. This contrast supports “can differ”; it is not a general statement that code ranges are unaffected by fixups.

A separate source-generated ELF64 maps two adjacent four-byte virtual regions to file offsets 0x1000 and 0x3000. Real Ghidra MCP read_bytes returned all eight bytes 1122334455667788 and complete in both profiles; the two address lookups returned those separate offsets. Reading eight contiguous file bytes from the first offset gave 1122334400000000. The unexecuted fixture SHA-256 remained e66ea8131ec8479d0fbfbdc2d57ff30137700d1956879602ff6b7bd289d54f3d. This supports the single-address offset caveat on one constructed mapping; no general ELF-loader claim is made.

On the same fixup fixture, a real Ghidra session exported the byte-read and file-offset Evidence; a fresh target-free MCP server imported the bundle and returned both records exactly, including the byte-read loader-fixup limitation, in compact and full profiles. This verifies one historical handoff, not a per-fixup Ghidra provenance record.

On that ELF, a four-byte Ghidra read starting two bytes before the end of mapped memory returned 7788, returned_bytes: 2, and complete: false in both MCP profiles. This checks the existing short-read contract on one boundary; the source hash remained unchanged.

Validation performed

  • npm run build:cached, npm run check:fast, npm run docs:check, and git diff --check — passed.
  • Real Ghidra MCP control described above — passed in both profiles, including after the final wording refinement; successful result schemas were not independently validated in this run.
  • CLI --help displayed both updated descriptions.

Compatibility, safety, and release

No breaking changes or migration. Catalog/help text changes; provider data, source identity, and Evidence remain unchanged.

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.

@greptile-apps

greptile-apps Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Low impact] This wording-only change appears safe to merge.

Summary

Clarifies the existing difference between analyzed memory and original file bytes in CLI help and MCP descriptions.

  • Memory tool descriptions explain when Ghidra bytes differ from file bytes.
  • File-offset descriptions limit a mapping to one address.

No actionable issues or new security concerns were found. Source checks matched the descriptions to the byte reader, file mapper, and catalog registration. git diff --check passed; no runtime tests were run during this review.

Supersession could not be checked because GitHub access required authentication.

Reviews (1) · Last reviewed commit: "docs(native): qualify Ghidra fixup cover..." · Reviewed by Greptile

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 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-04T16:55:18.176881Z 33f2d25 Draft marked ready
ℹ️ 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 merged commit 78d7bf3 into main Nov 4, 2026
57 of 60 checks passed
@morluto
morluto deleted the codex/ghidra-byte-source-contract branch November 4, 2026 17:41
@morluto morluto added area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior documentation Improvements or additions to documentation labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant