[PR #2194] [MERGED] fix(managed): report malformed PE layouts as invalid input #5078

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

📋 Pull Request Information

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

Base: main ← Head: fix/issue-2191


📝 Commits (2)

  • 7fc3f20 fix(managed): report malformed PE layouts as invalid input
  • 5eab9e6 fix(managed): route unmappable PE layouts through one input error

📊 Changes

3 files changed (+51 additions, -9 deletions)

View changed files

📝 src/dotnet/ManagedNativeBoundaryInspector.ts (+2 -9)
📝 src/dotnet/ManagedStaticProvider.ts (+16 -0)
📝 tests/acceptance/managedCliOutput.test.ts (+33 -0)

📄 Description

Summary

readManagedPeLayout throws ManagedReaderFailure for DOS, COFF and section-header failures, for example a section whose raw data lies past EOF. inspectManagedArtifactBytes and inspectManagedMembersBytes only convert failures raised after the layout is read. These layout failures therefore reached ManagedStaticProvider.execute, which wrapped them as ProviderAdapterError. The CLI and MCP then reported execution_failure with "Run rea doctor …", and the reader's precise detail was lost.

The provider now maps a ManagedReaderFailure (other than resource-limit) to an AnalysisInputError whose invalid_format issue carries the reader's detail. This matches how inspect-pe-resources and inspect-go-binary report the same bytes.

inspect-managed-native-boundaries used to catch this layout-level failure itself and return an empty malformed inspection with exit 0. It now lets the failure reach the same mapping, so all three managed operations report an unmappable PE layout as invalid input. Metadata failures after a readable layout keep their structured malformed coverage.

Fixes #2191

Before / after (VS Code's Microsoft.PowerShell.Pager.dll with its first section's PointerToRawData set past EOF)

inspect-managed-artifact / inspect-managed-members
before: execution_failure — "Analysis could not complete. Run `rea doctor` …", details: {"provider_id":"rea-dotnet-static", …}
after:  invalid_request — issues: [{"path":["path"],"reason":"invalid_format","message":"Selected artifact …/section-past-eof.dll: pe.section-data leaves the artifact byte range"}]

Well-formed assemblies are unaffected. I found this by mutation-fuzzing real managed DLLs: before the change, 4 of 192 mutated inputs reached this path.

Validation

  • New acceptance test managed CLI reports a section table past EOF as invalid input (tests/acceptance/managedCliOutput.test.ts). It corrupts buildManagedPeFixture()'s first section pointer and checks all three managed commands. It fails on main and passes with this change; all 7 tests in the file pass.
  • npm run lint passes.
  • npm test: 9155 passed, 14 failed in 7 files. These are the same environmental files that fail on clean origin/main on this host: Hopper not installed, Command Line Tools only (ibtool), hdiutil, and inspector target-location cases.

🤖 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/2194 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/12/2026 **Status:** ✅ Merged **Merged:** 10/12/2026 **Merged by:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Base:** `main` ← **Head:** `fix/issue-2191` --- ### 📝 Commits (2) - [`7fc3f20`](https://github.com/morluto/rea/commit/7fc3f208e7848bb95bb52f6b87cf4d6e7c230fc7) fix(managed): report malformed PE layouts as invalid input - [`5eab9e6`](https://github.com/morluto/rea/commit/5eab9e685c44ee16ca18c84edda8521c5d7f6743) fix(managed): route unmappable PE layouts through one input error ### 📊 Changes **3 files changed** (+51 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `src/dotnet/ManagedNativeBoundaryInspector.ts` (+2 -9) 📝 `src/dotnet/ManagedStaticProvider.ts` (+16 -0) 📝 `tests/acceptance/managedCliOutput.test.ts` (+33 -0) </details> ### 📄 Description ## Summary `readManagedPeLayout` throws `ManagedReaderFailure` for DOS, COFF and section-header failures, for example a section whose raw data lies past EOF. `inspectManagedArtifactBytes` and `inspectManagedMembersBytes` only convert failures raised after the layout is read. These layout failures therefore reached `ManagedStaticProvider.execute`, which wrapped them as `ProviderAdapterError`. The CLI and MCP then reported `execution_failure` with "Run `rea doctor` …", and the reader's precise detail was lost. The provider now maps a `ManagedReaderFailure` (other than `resource-limit`) to an `AnalysisInputError` whose `invalid_format` issue carries the reader's detail. This matches how `inspect-pe-resources` and `inspect-go-binary` report the same bytes. `inspect-managed-native-boundaries` used to catch this layout-level failure itself and return an empty `malformed` inspection with exit 0. It now lets the failure reach the same mapping, so all three managed operations report an unmappable PE layout as invalid input. Metadata failures after a readable layout keep their structured `malformed` coverage. Fixes #2191 ## Before / after (VS Code's `Microsoft.PowerShell.Pager.dll` with its first section's PointerToRawData set past EOF) ```text inspect-managed-artifact / inspect-managed-members before: execution_failure — "Analysis could not complete. Run `rea doctor` …", details: {"provider_id":"rea-dotnet-static", …} after: invalid_request — issues: [{"path":["path"],"reason":"invalid_format","message":"Selected artifact …/section-past-eof.dll: pe.section-data leaves the artifact byte range"}] ``` Well-formed assemblies are unaffected. I found this by mutation-fuzzing real managed DLLs: before the change, 4 of 192 mutated inputs reached this path. ## Validation - New acceptance test `managed CLI reports a section table past EOF as invalid input` (`tests/acceptance/managedCliOutput.test.ts`). It corrupts `buildManagedPeFixture()`'s first section pointer and checks all three managed commands. It fails on main and passes with this change; all 7 tests in the file pass. - `npm run lint` passes. - `npm test`: 9155 passed, 14 failed in 7 files. These are the same environmental files that fail on clean `origin/main` on this host: Hopper not installed, Command Line Tools only (`ibtool`), `hdiutil`, and inspector target-location cases. 🤖 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:03:11 +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#5078
No description provided.