Skip to content

fix(managed): report malformed PE layouts as invalid input - #2194

Merged
kaoru0822-kitauji merged 2 commits into
mainfrom
fix/issue-2191
Oct 12, 2026
Merged

kaoru0822-kitauji merged 2 commits into
mainfrom
fix/issue-2191

Conversation

@kaoru0822-kitauji

@kaoru0822-kitauji kaoru0822-kitauji commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

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

readManagedPeLayout raises ManagedReaderFailure for DOS, COFF and section
header failures such as section data past EOF. Those escaped the managed
inspectors, so ManagedStaticProvider wrapped them as ProviderAdapterError
and the CLI and MCP reported execution_failure with advice to run rea
doctor. Map format failures to an invalid_format input issue carrying the
reader's detail, as inspect-pe-resources and inspect-go-binary do.

Fixes #2191

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 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-10-12T13:15:06.968660Z 5eab9e6 New commits
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7fc3f208e7

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +141 to +144
if (
cause instanceof ManagedReaderFailure &&
cause.issue.code !== "resource-limit"
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Make malformed layout handling consistent for native boundaries

When inspect-managed-native-boundaries receives the same PE whose section data extends past EOF, it still succeeds: inspectManagedNativeBoundariesBytes catches the ManagedReaderFailure from readManagedPeLayout and returns a malformed empty inspection, so this new provider-level conversion is never reached. The command therefore exits 0 and emits Evidence while the other two managed commands now return invalid_request; route this layout failure through the same input-error path or add an intentional operation-specific policy.

AGENTS.md reference: AGENTS.md:L23-L23

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 5eab9e6. inspect-managed-native-boundaries no longer catches the layout-level ManagedReaderFailure from readManagedPeLayout, so an unmappable PE layout (DOS/COFF/section table) reaches the same provider mapping and returns invalid_request / invalid_format for all three managed operations. Metadata failures after a readable layout keep their existing structured malformed coverage; the native-boundary unit tests for those cases pass unchanged. The acceptance test now asserts all three commands on the section-past-EOF fixture.

inspect-managed-native-boundaries caught a layout-level ManagedReaderFailure
itself and returned an empty malformed inspection with exit 0, while the
other managed operations now report the same bytes as invalid input. Let
the layout failure reach the provider's invalid_format mapping; metadata
failures after a readable layout still return malformed coverage.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kaoru0822-kitauji
kaoru0822-kitauji merged commit 90e37f4 into main Oct 12, 2026
30 checks passed
@kaoru0822-kitauji
kaoru0822-kitauji deleted the fix/issue-2191 branch October 12, 2026 13:53
@github-actions github-actions Bot mentioned this pull request Oct 12, 2026
3 tasks done
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 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 bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Malformed PE section headers make managed inspection report execution_failure instead of invalid input

2 participants