Repository navigation
feat(pe): inspect TLS callbacks and load configuration - #7008
Merged
Merged
Conversation
Adds inspect-pe-load-config and inspect_pe_load_config for PE32 and PE32+ images, with artifact hashes and file ranges in the returned evidence. Reports callback addresses and mappings, plus size-covered security-cookie, SafeSEH, CFG, EH-continuation and XFG fields; flag-derived mitigation claims are explicitly labeled inferred. Missing directories remain null, and malformed storage or exhausted read budgets return errors without partial success. Adds documentation and tests for service validation, CLI/MCP access, malformed inputs and stable-file handling. x86 images that declare the legacy 64-byte load-config directory are read to the structure's own Size when those bytes are file-backed, as the Windows loader does. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016y53PdpyMAp9RSW65fatHe
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. |
Contributor
[Medium impact] The reviewed changes appear safe to merge, with all four previous findings addressed. SummaryAdds static PE32/PE32+ TLS callback and load-configuration inspection through CLI and MCP.
Reviews (2) · Last reviewed commit: "fix(pe): retain snapshot facts and bound..." · Reviewed by Greptile |
Keep the completed stable-read path, SHA-256 and byte count as a file-snapshot-hash partial observation when descriptor close fails or is cancelled. Report the checked Size span as structure_location and add it to Evidence locations beside the declared directory range. Resolve callback sections through a sorted segment index built once per image, keeping the ambiguity failure. Pin every load-config field to offsets transcribed from the PE/COFF spec and llvm COFF.h at its exact Size boundary for PE32 and PE32+. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016y53PdpyMAp9RSW65fatHe
3 tasks done
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TLS callbacks run before a PE image's entry point, and the load configuration declares the security cookie, SafeSEH table and Control Flow Guard metadata. REA can inspect PE imports, resources and certificates, but had no static view of either directory. This adds
inspect-pe-load-config(CLI) andinspect_pe_load_config(MCP) for PE32 and PE32+ images, read without executing the image or opening a disassembler. No related issue; this is a new static inspection within existing native authority.Problem and expected behavior
An analyst asking "what runs before
main?" or "which mitigations does this image declare?" today needsllvm-readobj,dumpbinor a disassembler. Expected: REA returns the TLS directory and its null-terminated callback array (each callback VA with RVA, file offset and section), and the load configuration fields its declaredSizecovers, with flag-derived mitigation claims labeled inferred.Change and scope
src/native/pe/PeLoadConfigParser.tsreuses the shared PE image reader and file-mapping index. Callback VAs are hexadecimal strings to keep 64-bit precision; unmapped targets keep their VA with an unknown file offset. Load-config fields are reported only whenSizecovers the whole field.MSVC x86 images commonly declare a 64-byte load-config data directory while the structure's
Sizeis larger (188 bytes on the sample below). Like the Windows loader, the parser readsSizebytes when they are file-backed in one run and reports both values; otherwise it fails as malformed.Budgets: 64 MiB file read (ceiling 512 MiB), 64 callbacks (ceiling 4096). Truncated, ambiguous or unmapped directory storage fails closed with no partial success. Not included: decoding CHPE or dynamic relocation tables, or verifying that CFG instructions are present. AI was used for assistance.
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 readiness and merge checklists
unchecked. Maintainers can help resolve open questions.
Contract and boundary impact
src/native/pe/) and the binary diagnostics service.inspect-pe-load-configcommand andinspect_pe_load_configtool withpath,max_file_bytesandmax_callbacksinputs.evidence_kind: "inferred".docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs andskills/; edit authored instructions in.agents/skills/reverse-engineer-anything/and never commit build outputs): catalog builder entry, authored skill guidance in.agents/skills/reverse-engineer-anything/, and averify:pe:load-configpackage script. No committed build outputs.Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
Evidence and regression coverage
src/native/pe/PeLoadConfigParser.test.ts(PE32 and PE32+ synthetic images: callbacks, Size-covered fields, the legacy 64-byte PE32 directory, budgets, malformed and ambiguous storage),PeLoadConfigService.test.ts,tests/acceptance/peLoadConfigCli.test.ts,tests/boundary/mcp/peLoadConfigMcp.test.ts,tests/boundary/filesystem/peLoadConfig.test.ts, and the shared tool-contract and stable-artifact lists. Fixtures are synthetic; no binaries are committed.llvm-readobj --coff-tls-directoryand--coff-load-configon local, uncommitted binaries: a MinGW-linked PE32+ TLS sample, and Sysinternalsstrings64.exeandstrings.exe(MSVC). Details are indocs/verification/pe-load-config-2026-10-24.md.llvm-readobj --coff-load-config strings.exereportsSize: 0xBC,SecurityCookie: 0x4560DC,SEHandlerTable: 0x453B28,SEHandlerCount: 7,GuardFlags: 0x100.For evidence-bearing changes:
Validation performed
Head
f2346e4d5on maind361c53c5; macOS arm64, Node 26.5.0, npm 12.2.0:npx --no-install vitest run src/application/binaryDiagnostics/PeLoadConfigService.test.ts src/contracts/toolEffects.test.ts src/native/pe/PeLoadConfigParser.test.ts tests/acceptance/peLoadConfigCli.test.ts tests/acceptance/tools/localToolContracts.test.ts tests/boundary/filesystem/peLoadConfig.test.ts tests/boundary/mcp/peLoadConfigMcp.test.ts tests/process-global/stableArtifactConsumers.test.ts- passed.npm run verify:pe:load-configwith Zig 0.16.0 - PE32 and PE32+ samples inspected; neither image was started.strings.exe(PE32, MSVC) matches thellvm-readobjfields shown above.Compatibility, safety, and release
verify:pe:load-config).Author readiness
Human owner: @mvanhorn
Before merge
type(scope): outcome.Demo