Repository navigation
fix(managed): report malformed PE layouts as invalid input - #2194
Conversation
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>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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".
| if ( | ||
| cause instanceof ManagedReaderFailure && | ||
| cause.issue.code !== "resource-limit" | ||
| ) |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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>
Summary
readManagedPeLayoutthrowsManagedReaderFailurefor DOS, COFF and section-header failures, for example a section whose raw data lies past EOF.inspectManagedArtifactBytesandinspectManagedMembersBytesonly convert failures raised after the layout is read. These layout failures therefore reachedManagedStaticProvider.execute, which wrapped them asProviderAdapterError. The CLI and MCP then reportedexecution_failurewith "Runrea doctor…", and the reader's precise detail was lost.The provider now maps a
ManagedReaderFailure(other thanresource-limit) to anAnalysisInputErrorwhoseinvalid_formatissue carries the reader's detail. This matches howinspect-pe-resourcesandinspect-go-binaryreport the same bytes.inspect-managed-native-boundariesused to catch this layout-level failure itself and return an emptymalformedinspection 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 structuredmalformedcoverage.Fixes #2191
Before / after (VS Code's
Microsoft.PowerShell.Pager.dllwith its first section's PointerToRawData set past EOF)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
managed CLI reports a section table past EOF as invalid input(tests/acceptance/managedCliOutput.test.ts). It corruptsbuildManagedPeFixture()'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 lintpasses.npm test: 9155 passed, 14 failed in 7 files. These are the same environmental files that fail on cleanorigin/mainon this host: Hopper not installed, Command Line Tools only (ibtool),hdiutil, and inspector target-location cases.🤖 Generated with Claude Code