[PR #4596] [CLOSED] fix(ghidra): reject seed files that grow during commitment read #6329

Closed
opened 2026-10-31 01:13:37 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4596
Author: @nikhilsaxena04
Created: 10/16/2026
Status: ❌ Closed

Base: main ← Head: fix/4586-ghidra-seed-read-extent


📝 Commits (1)

  • 485d524 fix(ghidra): reject seed files that grow during commitment read

📊 Changes

1 file changed (+18 additions, -0 deletions)

View changed files

📝 src/ghidra/GhidraAnalysisSeeds.test.ts (+18 -0)

📄 Description

Summary

Reject seed files that grow during commitment reading by verifying that no trailing bytes exist beyond the admitted read extent and confirming metadata consistency in readSeedFile. Fixes #4586.

Problem and expected behavior

When committing Ghidra analysis seeds in resolveGhidraAnalysisSeeds, readSeedFile previously obtained the initial file size via stat.size, allocated a buffer for that exact length, and read the extent. If the seed file grew concurrently on disk (for example, via another process writing additional seed entries before read completion), the extra bytes were silently ignored. The profile then committed an unexamined prefix as if it represented the entire seed file.

The expected behavior (matching the neighboring extension reader in GhidraExtensions.ts) is to fail closed if the file changes or grows during read, preserving source identity and uncertainty rather than committing an incomplete seed set.

Change and scope

  • In src/ghidra/GhidraAnalysisSeeds.ts:readSeedFile, added a post-read check that attempts to read an additional byte past the initial stat size (file.read(extra, 0, 1, offset)) and verifies that postStat.size === stat.size.
  • Throws an error (Ghidra seed file changed during read: ${path}) when trailing bytes or file size changes are detected, which resolveGhidraAnalysisSeeds maps to a typed ProviderAdapterError.
  • Added regression test refuses a seed file that grows during its read in src/ghidra/GhidraAnalysisSeeds.test.ts using holdFirstFileRead.

Follow the contribution scope.

Contract and boundary impact

  • Semantic owner and earliest changed stage: GhidraAnalysisSeeds provider profile resolution.
  • Contribution scope fit and linked maintainer decision: Bug fix enforcing read extent integrity and bounded seed commitment; within existing scope.
  • CLI and MCP/tool-catalog contract: Unchanged.
  • Provider, bridge, target-format, or platform compatibility: Cross-platform regular file reading.
  • Evidence, artifact, provenance, or reconstruction contract: Preserves source identity by preventing stale/truncated seed commitments.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): None.
  • Generated metadata, package, or installation impact: None.

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

  • Tests added or updated: src/ghidra/GhidraAnalysisSeeds.test.ts (refuses a seed file that grows during its read)
  • Base reproduction or other evidence: Verified with controlled file growth during active read using holdFirstFileRead.
  • User-visible CLI/MCP output: Concurrent file modification during profile resolution returns a typed error rather than silently accepting truncated seeds.
  • Remaining proof gaps: None.

For evidence-bearing changes:

  • 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

  • npx vitest run src/ghidra/GhidraAnalysisSeeds.test.ts — 22/22 passed.
  • npm run check:fast — 2/2 tasks successful (turbo typecheck and lint).
  • npx oxfmt --check src/ghidra/GhidraAnalysisSeeds.ts src/ghidra/GhidraAnalysisSeeds.test.ts — All files match formatting rules.

Compatibility, safety, and release

  • Breaking changes or migration steps: None.
  • Real Hopper/Ghidra, browser, or OS coverage: Cross-platform Node.js file operations.
  • Package or release metadata impact: None.
  • Security, privacy, process, or containment review: Preserves bounded read and input integrity invariants.

Author readiness

Human owner: @nikhilsaxena04

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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/4596 **Author:** [@nikhilsaxena04](https://github.com/nikhilsaxena04) **Created:** 10/16/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/4586-ghidra-seed-read-extent` --- ### 📝 Commits (1) - [`485d524`](https://github.com/morluto/rea/commit/485d52428b127a27ce1accc41b476262eaf0b6ae) fix(ghidra): reject seed files that grow during commitment read ### 📊 Changes **1 file changed** (+18 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/ghidra/GhidraAnalysisSeeds.test.ts` (+18 -0) </details> ### 📄 Description ## Summary Reject seed files that grow during commitment reading by verifying that no trailing bytes exist beyond the admitted read extent and confirming metadata consistency in `readSeedFile`. Fixes #4586. ## Problem and expected behavior When committing Ghidra analysis seeds in `resolveGhidraAnalysisSeeds`, `readSeedFile` previously obtained the initial file size via `stat.size`, allocated a buffer for that exact length, and read the extent. If the seed file grew concurrently on disk (for example, via another process writing additional seed entries before read completion), the extra bytes were silently ignored. The profile then committed an unexamined prefix as if it represented the entire seed file. The expected behavior (matching the neighboring extension reader in `GhidraExtensions.ts`) is to fail closed if the file changes or grows during read, preserving source identity and uncertainty rather than committing an incomplete seed set. ## Change and scope - In `src/ghidra/GhidraAnalysisSeeds.ts:readSeedFile`, added a post-read check that attempts to read an additional byte past the initial stat size (`file.read(extra, 0, 1, offset)`) and verifies that `postStat.size === stat.size`. - Throws an error (`Ghidra seed file changed during read: ${path}`) when trailing bytes or file size changes are detected, which `resolveGhidraAnalysisSeeds` maps to a typed `ProviderAdapterError`. - Added regression test `refuses a seed file that grows during its read` in `src/ghidra/GhidraAnalysisSeeds.test.ts` using `holdFirstFileRead`. Follow the [contribution scope](https://github.com/morluto/rea/blob/main/CONTRIBUTING.md#contribution-scope). ## Contract and boundary impact - Semantic owner and earliest changed stage: `GhidraAnalysisSeeds` provider profile resolution. - Contribution scope fit and linked maintainer decision: Bug fix enforcing read extent integrity and bounded seed commitment; within existing scope. - CLI and MCP/tool-catalog contract: Unchanged. - Provider, bridge, target-format, or platform compatibility: Cross-platform regular file reading. - Evidence, artifact, provenance, or reconstruction contract: Preserves source identity by preventing stale/truncated seed commitments. - Target selection, authority, upstream behavior, and cleanup details (if applicable): None. - Generated metadata, package, or installation impact: None. Expected effects: - [x] 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 - Tests added or updated: `src/ghidra/GhidraAnalysisSeeds.test.ts` (`refuses a seed file that grows during its read`) - Base reproduction or other evidence: Verified with controlled file growth during active read using `holdFirstFileRead`. - User-visible CLI/MCP output: Concurrent file modification during profile resolution returns a typed error rather than silently accepting truncated seeds. - Remaining proof gaps: None. For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - `npx vitest run src/ghidra/GhidraAnalysisSeeds.test.ts` — 22/22 passed. - `npm run check:fast` — 2/2 tasks successful (turbo typecheck and lint). - `npx oxfmt --check src/ghidra/GhidraAnalysisSeeds.ts src/ghidra/GhidraAnalysisSeeds.test.ts` — All files match formatting rules. ## Compatibility, safety, and release - Breaking changes or migration steps: None. - Real Hopper/Ghidra, browser, or OS coverage: Cross-platform Node.js file operations. - Package or release metadata impact: None. - Security, privacy, process, or containment review: Preserves bounded read and input integrity invariants. ## Author readiness Human owner: @nikhilsaxena04 - [x] 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. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:13:37 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#6329
No description provided.