[PR #3094] [CLOSED] feat(pe): inspect IMAGE_DEBUG_DIRECTORY without executing the image #5612

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/3094
Author: @mvanhorn
Created: 10/14/2026
Status: ❌ Closed

Base: main ← Head: fix/pe-debug-directory


📝 Commits (3)

  • 635d14b feat(pe): inspect IMAGE_DEBUG_DIRECTORY without executing the image
  • 7d6bed5 Merge remote-tracking branch 'origin/main' into HEAD
  • 7175dca fix(pe): bound debug payload decoding and fix REPRO and MISC layouts

📊 Changes

30 files changed (+1733 additions, -11 deletions)

View changed files

📝 .agents/skills/reverse-engineer-anything/SKILL.md (+5 -0)
📝 .agents/skills/reverse-engineer-anything/references/native-and-artifacts.md (+12 -0)
📝 docs/binary-diagnostics.md (+37 -0)
📝 docs/cli.md (+11 -0)
📝 docs/index.md (+1 -1)
📝 scripts/lib/catalog-builders.mjs (+10 -1)
📝 src/application/CapabilityInventory.ts (+1 -1)
📝 src/application/InvestigationProviders.ts (+7 -0)
➕ src/application/binaryDiagnostics/PeDebugDirectoryPort.ts (+20 -0)
➕ src/application/binaryDiagnostics/PeDebugDirectoryService.test.ts (+82 -0)
➕ src/application/binaryDiagnostics/PeDebugDirectoryService.ts (+102 -0)
📝 src/cli/binaryDiagnosticsCommands.ts (+34 -0)
📝 src/cliCommandNames.ts (+1 -0)
📝 src/composition/binaryDiagnostics.ts (+6 -0)
📝 src/contracts/native/binaryDiagnosticsToolContracts.ts (+19 -0)
📝 src/contracts/toolEffects.test.ts (+2 -0)
📝 src/contracts/toolEffects.ts (+1 -0)
➕ src/domain/native/peDebugDirectory.test.ts (+105 -0)
➕ src/domain/native/peDebugDirectory.ts (+239 -0)
➕ src/native/pe/PeDebugDirectory.fixture.ts (+128 -0)

...and 10 more files

📄 Description

Summary

Adds inspect_pe_debug_directory / inspect-pe-debug-directory so an analyst can inventory one explicit local PE32/PE32+ IMAGE_DEBUG_DIRECTORY without executing the image, opening a disassembler, or fetching a PDB. No linked issue: this is a focused format-inspection workflow; closed #362 already covered broader PE/COFF/PDB static inspection.

Problem and expected behavior

Analysts need CodeView RSDS/NB10 PDB path, GUID and age, REPRO hashes, and EX_DLLCHARACTERISTICS from a selected PE without treating a missing directory as proof the image was built without debug information. The new operation reads one stable regular file and returns a complete bounded inventory, or a typed failure with no partial success.

Change and scope

A portable in-process parser walks the PE data directory, each 28-byte debug entry, and known payload kinds. CodeView decoding reuses the existing CodeView owner. Intentionally not included: PDB download, symbol loading, disassembly, mutation, or execution.

Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the final review checklist
unchecked. Maintainers can help resolve open questions.

Contract and boundary impact

  • Semantic owner and earliest changed stage: domain peDebugDirectory schema; src/native/pe/PeDebugDirectoryParser.ts owns PE/debug-directory decoding; CLI/MCP share PeDebugDirectoryService.
  • Contribution scope fit and linked maintainer decision: format inspection of a caller-selected PE; not applicable (no execution, injection, mutation, or protection recovery).
  • CLI and MCP/tool-catalog contract: new inspect_pe_debug_directory / inspect-pe-debug-directory; MCP requires an absolute path; CLI resolves relative paths.
  • Provider, bridge, target-format, or platform compatibility: bundled rea-pe-debug-directory reader; PE32/PE32+ on supported Node hosts; no Windows SDK.
  • Evidence, artifact, provenance, or reconstruction contract: observed Evidence bound to the selected path and SHA-256; missing directory is empty inventory with an explicit limitation.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): explicit local regular file only; no process launch; owned snapshot cleanup retained on failure.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs): authored skill and docs updated; catalogs remain generated/uncommitted.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • 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: domain schema, parser (RSDS and missing directory), service input/Evidence locations, filesystem admission, CLI, MCP advertisement and absolute-path rejection.
  • Base reproduction or other evidence: source-owned PE fixtures with CodeView RSDS and an empty data directory.
  • User-visible CLI/MCP output (if applicable): JSON Evidence with entries[].payload.decoded.kind === "codeview_rsds" and PDB file name sample.pdb.
  • Remaining proof gaps: real Windows PE corpus and NB10/REPRO payloads are covered in source fixtures, not a live Windows host run.

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:local -- src/domain/native/peDebugDirectory.test.ts src/native/pe/PeDebugDirectoryParser.test.ts src/application/binaryDiagnostics/PeDebugDirectoryService.test.ts — pass
  • npm run test:focused -- tests/acceptance/peDebugDirectoryCli.test.ts tests/boundary/filesystem/peDebugDirectory.test.ts tests/boundary/mcp/peDebugDirectoryMcp.test.ts — pass
  • npm run check — pass (typecheck, lint, format, knip, architecture guards)
  • npm run docs:check — pass
  • npm run verify:test-discovery — pass
  • node scripts/rea.mjs inspect-pe-debug-directory /tmp/rea-pe-debug-demo/sample.exe --json — CodeView RSDS sample.pdb, GUID 04030201-0605-0807-090a-0b0c0d0e0f10, age 7

Compatibility, safety, and release

  • Breaking changes or migration steps: none; additive tool and CLI command.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable; no engine or GUI.
  • Package or release metadata impact: new public tool name in the generated catalog after CI.
  • Security, privacy, process, or containment review: read-only regular-file snapshot; no network; PDB paths are file content and are not fetched.

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.

Demo

demo


🔄 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/3094 **Author:** [@mvanhorn](https://github.com/mvanhorn) **Created:** 10/14/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/pe-debug-directory` --- ### 📝 Commits (3) - [`635d14b`](https://github.com/morluto/rea/commit/635d14b204fd47ffabb2860714b3358aa2b2f6f9) feat(pe): inspect IMAGE_DEBUG_DIRECTORY without executing the image - [`7d6bed5`](https://github.com/morluto/rea/commit/7d6bed59478916216941c09fa1df4d10d3d80359) Merge remote-tracking branch 'origin/main' into HEAD - [`7175dca`](https://github.com/morluto/rea/commit/7175dca9d22f9d6ec9fe0199f83f697545ad43c1) fix(pe): bound debug payload decoding and fix REPRO and MISC layouts ### 📊 Changes **30 files changed** (+1733 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `.agents/skills/reverse-engineer-anything/SKILL.md` (+5 -0) 📝 `.agents/skills/reverse-engineer-anything/references/native-and-artifacts.md` (+12 -0) 📝 `docs/binary-diagnostics.md` (+37 -0) 📝 `docs/cli.md` (+11 -0) 📝 `docs/index.md` (+1 -1) 📝 `scripts/lib/catalog-builders.mjs` (+10 -1) 📝 `src/application/CapabilityInventory.ts` (+1 -1) 📝 `src/application/InvestigationProviders.ts` (+7 -0) ➕ `src/application/binaryDiagnostics/PeDebugDirectoryPort.ts` (+20 -0) ➕ `src/application/binaryDiagnostics/PeDebugDirectoryService.test.ts` (+82 -0) ➕ `src/application/binaryDiagnostics/PeDebugDirectoryService.ts` (+102 -0) 📝 `src/cli/binaryDiagnosticsCommands.ts` (+34 -0) 📝 `src/cliCommandNames.ts` (+1 -0) 📝 `src/composition/binaryDiagnostics.ts` (+6 -0) 📝 `src/contracts/native/binaryDiagnosticsToolContracts.ts` (+19 -0) 📝 `src/contracts/toolEffects.test.ts` (+2 -0) 📝 `src/contracts/toolEffects.ts` (+1 -0) ➕ `src/domain/native/peDebugDirectory.test.ts` (+105 -0) ➕ `src/domain/native/peDebugDirectory.ts` (+239 -0) ➕ `src/native/pe/PeDebugDirectory.fixture.ts` (+128 -0) _...and 10 more files_ </details> ### 📄 Description ## Summary Adds `inspect_pe_debug_directory` / `inspect-pe-debug-directory` so an analyst can inventory one explicit local PE32/PE32+ `IMAGE_DEBUG_DIRECTORY` without executing the image, opening a disassembler, or fetching a PDB. No linked issue: this is a focused format-inspection workflow; closed #362 already covered broader PE/COFF/PDB static inspection. ## Problem and expected behavior Analysts need CodeView RSDS/NB10 PDB path, GUID and age, REPRO hashes, and `EX_DLLCHARACTERISTICS` from a selected PE without treating a missing directory as proof the image was built without debug information. The new operation reads one stable regular file and returns a complete bounded inventory, or a typed failure with no partial success. ## Change and scope A portable in-process parser walks the PE data directory, each 28-byte debug entry, and known payload kinds. CodeView decoding reuses the existing CodeView owner. Intentionally not included: PDB download, symbol loading, disassembly, mutation, or execution. Follow the [contribution scope](https://github.com/morluto/rea/blob/main/CONTRIBUTING.md#contribution-scope). Unresolved scope, authority, side effects, or required verification block integration. Link the required maintainer scope decision for new providers or capabilities involving target execution, injection, mutation, or protection recovery; ordinary fixes within existing boundaries may state "not applicable". Draft PRs may leave the scope decision pending and the final review checklist unchecked. Maintainers can help resolve open questions. ## Contract and boundary impact - Semantic owner and earliest changed stage: domain `peDebugDirectory` schema; `src/native/pe/PeDebugDirectoryParser.ts` owns PE/debug-directory decoding; CLI/MCP share `PeDebugDirectoryService`. - Contribution scope fit and linked maintainer decision: format inspection of a caller-selected PE; not applicable (no execution, injection, mutation, or protection recovery). - CLI and MCP/tool-catalog contract: new `inspect_pe_debug_directory` / `inspect-pe-debug-directory`; MCP requires an absolute path; CLI resolves relative paths. - Provider, bridge, target-format, or platform compatibility: bundled `rea-pe-debug-directory` reader; PE32/PE32+ on supported Node hosts; no Windows SDK. - Evidence, artifact, provenance, or reconstruction contract: observed Evidence bound to the selected path and SHA-256; missing directory is empty inventory with an explicit limitation. - Target selection, authority, upstream behavior, and cleanup details (if applicable): explicit local regular file only; no process launch; owned snapshot cleanup retained on failure. - Generated metadata (`docs/public/product-catalog.json`), package, or installation impact (CI generates and validates ignored catalogs and `skills/`; edit authored instructions in `.agents/skills/reverse-engineer-anything/` and never commit build outputs): authored skill and docs updated; catalogs remain generated/uncommitted. Expected effects (check known effects; use documentation-only on its own). Unchecked items do not establish absence; leave uncertainties visible. - [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: domain schema, parser (RSDS and missing directory), service input/Evidence locations, filesystem admission, CLI, MCP advertisement and absolute-path rejection. - Base reproduction or other evidence: source-owned PE fixtures with CodeView RSDS and an empty data directory. - User-visible CLI/MCP output (if applicable): JSON Evidence with `entries[].payload.decoded.kind === "codeview_rsds"` and PDB file name `sample.pdb`. - Remaining proof gaps: real Windows PE corpus and NB10/REPRO payloads are covered in source fixtures, not a live Windows host run. 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:local -- src/domain/native/peDebugDirectory.test.ts src/native/pe/PeDebugDirectoryParser.test.ts src/application/binaryDiagnostics/PeDebugDirectoryService.test.ts` — pass - `npm run test:focused -- tests/acceptance/peDebugDirectoryCli.test.ts tests/boundary/filesystem/peDebugDirectory.test.ts tests/boundary/mcp/peDebugDirectoryMcp.test.ts` — pass - `npm run check` — pass (typecheck, lint, format, knip, architecture guards) - `npm run docs:check` — pass - `npm run verify:test-discovery` — pass - `node scripts/rea.mjs inspect-pe-debug-directory /tmp/rea-pe-debug-demo/sample.exe --json` — CodeView RSDS `sample.pdb`, GUID `04030201-0605-0807-090a-0b0c0d0e0f10`, age `7` ## Compatibility, safety, and release - Breaking changes or migration steps: none; additive tool and CLI command. - Real Hopper/Ghidra, browser, or OS coverage: not applicable; no engine or GUI. - Package or release metadata impact: new public tool name in the generated catalog after CI. - Security, privacy, process, or containment review: read-only regular-file snapshot; no network; PDB paths are file content and are not fetched. ## 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. ## Demo ![demo](https://raw.githubusercontent.com/mvanhorn/pr-demo-assets/main/rea/pe-debug-directory/demo.gif) <video src="https://raw.githubusercontent.com/mvanhorn/pr-demo-assets/main/rea/pe-debug-directory/demo.mp4" controls width="720"></video> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:07:59 +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#5612
No description provided.