[PR #3904] [MERGED] fix(ghidra): refuse PSP targets with unexamined ABI declarations #5962

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/3904
Author: @kaoru0822-kitauji
Created: 10/15/2026
Status: ✅ Merged
Merged: 10/15/2026
Merged by: @kaoru0822-kitauji

Base: main ← Head: fix/ghidra-psp-incomplete-declarations


📝 Commits (1)

  • 5d2602a fix(ghidra): refuse PSP targets with unexamined ABI declarations

📊 Changes

3 files changed (+80 additions, -25 deletions)

View changed files

📝 src/ghidra/GhidraMipsProfile.ts (+16 -5)
📝 src/ghidra/GhidraPspProfile.ts (+3 -0)
📝 tests/boundary/filesystem/ghidraPspExtension.test.ts (+61 -20)

📄 Description

Summary

Fixes #3329. An ELF can declare a section-header table that lies beyond the captured file, so some of its headers were never read. MCP open_binary with provider ghidra admitted such a PSP ELF as supported. Target inspection said ABI declarations in those headers "remain unknown", yet the PSP lane still resolved a supported analysis profile. The generic MIPS lane already refuses this case.

Now the PSP lane refuses it with the same reason as the generic lane: MIPS ABI declaration inspection is incomplete; unsupported attributes or conflicting declaration sources may remain unknown. ....

Problem and expected behavior

ghidraMipsUnsupportedReason (generic MIPS) returns an incomplete-inspection reason whenever metadata.limitations is non-empty. Unexamined headers may hold declarations, such as GNU attributes or ABI flags, that would make the target unsupported. ghidraProcessorUnsupportedReason routes PSP targets to their own checks (flags 0x10a23001, the 24-byte ABI flags record, GNU attributes), and those checks never consulted limitations.

Change and scope

  • src/ghidra/GhidraMipsProfile.ts: the incomplete-declaration rule becomes ghidraMipsIncompleteDeclarationsReason(metadata). The generic lane calls it in the same position as before, with an identical message.
  • src/ghidra/GhidraPspProfile.ts: the PSP lane calls the same helper right after its GNU-attribute check, before trusting the ABI record.
  • Not included: other provider admission paths. The issue concerns the PSP lane, and the generic lane already enforces this rule.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Ghidra processor admission (GhidraPspProfile.ts) through the shared MIPS rule.
  • Contribution scope fit and linked maintainer decision: correctness fix enforcing the documented refusal; not applicable.
  • CLI and MCP/tool-catalog contract: schemas unchanged. Affected PSP targets are now unsupported with an explicit reason.
  • Provider, bridge, target-format, or platform compatibility: Ghidra PSP Allegrex lane only.
  • Evidence, artifact, provenance, or reconstruction contract: no admission based on unknown declarations.
  • Target selection, authority, upstream behavior, and cleanup details: the refusal happens before any Ghidra launch or extension use.
  • Generated metadata, package, or installation impact: none.

Expected effects:

  • Read existing files or captured data.

Evidence and regression coverage

  • Tests added in tests/boundary/filesystem/ghidraPspExtension.test.ts:
    • The existing real-reader PSP ELF is now built by a shared pspElfBytes() helper.
    • A new case writes the same image with e_shoff past EOF (e_shentsize 40, e_shnum 2) and reads it through the production parseBinaryTarget. It asserts that the ABI record still matches the PSP profile and that the target carries the unknown-declarations limitation. It also asserts inspectTargetSupport → unsupported and resolveAnalysisProfile → AnalysisUnsupportedTargetError with the incomplete-inspection message.
    • The complete-declaration control in the same file is still admitted.
  • Base reproduction: against the unfixed GhidraPspProfile.ts, the new case fails (1 failed | 42 passed).
  • Remaining proof gaps: no Ghidra installation or real PSP ELF was available locally. Coverage is the real target reader and provider admission with the synthetic ghidra-allegrex installation the suite already uses.

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

  • npm run test:focused -- tests/boundary/filesystem/mipsAbiFlags.test.ts tests/boundary/filesystem/mipsSharedLoad.test.ts src/ghidra/GhidraMipsProfile.test.ts tests/boundary/filesystem/ghidraPspExtension.test.ts: 183 passed
  • npm run check:fast, npm run knip: passed
  • Performance: the change adds one array-length check during admission and no new I/O.

Compatibility, safety, and release

  • Breaking changes or migration steps: none for completely inspected PSP ELFs. Images with unexamined headers are refused instead of admitted.
  • Real Hopper/Ghidra, browser, or OS coverage: Ghidra not installed locally; admission is verified before launch.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none.

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.

🤖 Generated with Claude Code


🔄 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/3904 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/15/2026 **Merged by:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Base:** `main` ← **Head:** `fix/ghidra-psp-incomplete-declarations` --- ### 📝 Commits (1) - [`5d2602a`](https://github.com/morluto/rea/commit/5d2602afdb207712a41a8a939244af1d964ea7ce) fix(ghidra): refuse PSP targets with unexamined ABI declarations ### 📊 Changes **3 files changed** (+80 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `src/ghidra/GhidraMipsProfile.ts` (+16 -5) 📝 `src/ghidra/GhidraPspProfile.ts` (+3 -0) 📝 `tests/boundary/filesystem/ghidraPspExtension.test.ts` (+61 -20) </details> ### 📄 Description ## Summary Fixes #3329. An ELF can declare a section-header table that lies beyond the captured file, so some of its headers were never read. MCP `open_binary` with provider `ghidra` admitted such a PSP ELF as supported. Target inspection said ABI declarations in those headers "remain unknown", yet the PSP lane still resolved a supported analysis profile. The generic MIPS lane already refuses this case. Now the PSP lane refuses it with the same reason as the generic lane: `MIPS ABI declaration inspection is incomplete; unsupported attributes or conflicting declaration sources may remain unknown. ...`. ## Problem and expected behavior `ghidraMipsUnsupportedReason` (generic MIPS) returns an incomplete-inspection reason whenever `metadata.limitations` is non-empty. Unexamined headers may hold declarations, such as GNU attributes or ABI flags, that would make the target unsupported. `ghidraProcessorUnsupportedReason` routes PSP targets to their own checks (flags `0x10a23001`, the 24-byte ABI flags record, GNU attributes), and those checks never consulted `limitations`. ## Change and scope - `src/ghidra/GhidraMipsProfile.ts`: the incomplete-declaration rule becomes `ghidraMipsIncompleteDeclarationsReason(metadata)`. The generic lane calls it in the same position as before, with an identical message. - `src/ghidra/GhidraPspProfile.ts`: the PSP lane calls the same helper right after its GNU-attribute check, before trusting the ABI record. - Not included: other provider admission paths. The issue concerns the PSP lane, and the generic lane already enforces this rule. ## Contract and boundary impact - Semantic owner and earliest changed stage: Ghidra processor admission (`GhidraPspProfile.ts`) through the shared MIPS rule. - Contribution scope fit and linked maintainer decision: correctness fix enforcing the documented refusal; not applicable. - CLI and MCP/tool-catalog contract: schemas unchanged. Affected PSP targets are now `unsupported` with an explicit reason. - Provider, bridge, target-format, or platform compatibility: Ghidra PSP Allegrex lane only. - Evidence, artifact, provenance, or reconstruction contract: no admission based on unknown declarations. - Target selection, authority, upstream behavior, and cleanup details: the refusal happens before any Ghidra launch or extension use. - Generated metadata, package, or installation impact: none. Expected effects: - [x] Read existing files or captured data. ## Evidence and regression coverage - Tests added in `tests/boundary/filesystem/ghidraPspExtension.test.ts`: - The existing real-reader PSP ELF is now built by a shared `pspElfBytes()` helper. - A new case writes the same image with `e_shoff` past EOF (`e_shentsize` 40, `e_shnum` 2) and reads it through the production `parseBinaryTarget`. It asserts that the ABI record still matches the PSP profile and that the target carries the unknown-declarations limitation. It also asserts `inspectTargetSupport` → `unsupported` and `resolveAnalysisProfile` → `AnalysisUnsupportedTargetError` with the incomplete-inspection message. - The complete-declaration control in the same file is still admitted. - Base reproduction: against the unfixed `GhidraPspProfile.ts`, the new case fails (`1 failed | 42 passed`). - Remaining proof gaps: no Ghidra installation or real PSP ELF was available locally. Coverage is the real target reader and provider admission with the synthetic `ghidra-allegrex` installation the suite already uses. 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 - `npm run test:focused -- tests/boundary/filesystem/mipsAbiFlags.test.ts tests/boundary/filesystem/mipsSharedLoad.test.ts src/ghidra/GhidraMipsProfile.test.ts tests/boundary/filesystem/ghidraPspExtension.test.ts`: 183 passed - `npm run check:fast`, `npm run knip`: passed - Performance: the change adds one array-length check during admission and no new I/O. ## Compatibility, safety, and release - Breaking changes or migration steps: none for completely inspected PSP ELFs. Images with unexamined headers are refused instead of admitted. - Real Hopper/Ghidra, browser, or OS coverage: Ghidra not installed locally; admission is verified before launch. - Package or release metadata impact: none. - Security, privacy, process, or containment review: none. ## Author readiness Human owner: <!-- @GitHub-handle --> - [ ] 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 - [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. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:10:46 +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#5962
No description provided.