Skip to content

fix(windows): reject native addons with unusable delay-import tables - #15066

Closed
ShuaixinHuang wants to merge 8 commits into
morluto:mainfrom
ShuaixinHuang:fix/windows-delay-import-directory-validation
Closed

ShuaixinHuang wants to merge 8 commits into
morluto:mainfrom
ShuaixinHuang:fix/windows-delay-import-directory-validation

Conversation

@ShuaixinHuang

@ShuaixinHuang ShuaixinHuang commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Replaces #15011 at the same commit 96f7134e403a1f295c87686fb4e28264fb77a998. The prior PR records the review history and validation for this commit.

Replaces #14993 at the same commit 96f7134e403a1f295c87686fb4e28264fb77a998. The prior PR records the review history and validation for this commit.

Replaces #14959 at the same commit 96f7134e403a1f295c87686fb4e28264fb77a998. The prior PR records the review history and validation for this commit.

Replaces #14869 at the same commit 96f7134e403a1f295c87686fb4e28264fb77a998. The prior PR records the review history and validation for this commit.

Replaces #14712 at the same commit 96f7134e403a1f295c87686fb4e28264fb77a998. The prior PR records the review history and validation for this commit.

Summary

Reject Windows native addons with unusable delay-import tables before writing their manifest or accepting the artifact for publication.

The earlier check accepted a two-import table when only its first eight-byte IAT slot was file-backed and writable. A matching digest establishes artifact identity, so malformed linker output could still pass publication checks. The shared owner now derives the complete IAT span from the import-name table (INT), validates every function slot and matching terminators, and checks descriptor termination. Read-only name tables and null sentinels remain valid, as does GNU ld's null descriptor immediately after the advertised directory size. Both the build and source/packed verifier consume this owner.

Replaces #14258 and addresses the full-table review finding. Main 0f4ec6231 is merged; the effective Windows change remains six files.

Evidence and validation

  • Restoring the published bda177e owner in the merged checkout made the production-verifier regression fail: it exited successfully with an unmapped second IAT slot. Source and source-free verifier regressions reject unmapped/read-only later function slots, mismatched termination and an early IAT null. Controls accept split writable mappings, read-only INTs and read-only null sentinels. Every artifact mutation receives a matching manifest digest.
  • An unmodified npm [email protected] addon passed read-only qualification (SHA-256 801a9994a5edaef8479d63a8ffed08c52013f5c044a6a04b0a3164cd60bee9a5). An independent PE walk found 34 Node-API imports, a read-only .rdata INT and writable .didat IAT. Narrowing only .didat's raw/virtual extent from 512 to 8 bytes produced a derivative accepted by the published owner and refused by this fix. Neither artifact was executed locally.
  • CI on 9192b0d4 passed the real MinGW build, Windows capability controls, and Windows package/CLI/MCP gate. The built addon digest was a475375514d4797e7a12c5327212cde42cc076d10b8c83c40cb02b817caf2ad2. All 12 built-test shards, source tests, static checks, build and docs also passed. That run's aggregate result was failure from a macOS CORE/dyld_info test; main's already-landed producer fix and captured-exit oracle are now merged as-is. These hosted results qualify 9192b0d4, not the new merge commit.
  • Fresh local checks on 169d00b5: the focused Windows domain/loader/public verifier and Mach-O refusal-provider/CLI tests passed 92 tests in five files, with one actual-Darwin-only test skipped; the normal runtime/skill build passed. Full typecheck, lint, formatting, ordinary Knip, metadata, architecture guards and production reachability passed. The entire default typed-lint inventory passed in four disjoint same-rule batches: 8,230 files, 0 errors, retaining 6,058 warnings, with unchanged source hashes.
  • npm run docs:check passed (8 README tests); discovery found all 3,914 test/spec files exactly once. npm run verify:package passed on Linux, including archive/install/update, CLI workflows and extracted-package MCP/Evidence. npm pack --dry-run --json passed.

Verification limits

Linux, Node 24.22.1/npm 11.16.0; task-local writable npm cache and NODE_USE_ENV_PROXY=1. No actual Windows or macOS execution was repeated locally. Fresh hosted CI on 169d00b5 completed with failure: its MinGW prerequisite download exceeded the 120-second APT deadline (exit 124), before compilation or artifact validation; downstream Windows/native-package lanes were skipped. The actual Apple lane passed (12 curated files: 201 passed/4 skipped; all 78 macOS-gated files: 905 passed/8 skipped), as did all 12 built-test shards, source tests, portable tests, static checks, build and docs. The failed-job rerun request was rejected by the connected GitHub integration with HTTP 403 (Resource not accessible by integration); a repository account with Actions write permission must rerun the failed jobs. No fresh 169d00b5 Windows success is claimed. The previous monolithic npm run check was stopped in typed lint at approximately 5 GiB RSS; the final static components and complete current typed inventory passed separately as described above. No single-process full-gate success is claimed.

Replaces #14453 at the same commit. See the previous PR for the review history.

Author readiness

Human owner: @ShuaixinHuang

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

@greptile-apps

greptile-apps Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The reviewed changes appear safe to merge.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The reviewed changes appear safe to merge.

Summary

The PR adds a shared check for Windows delay-import tables before manifest creation and artifact acceptance.

  • Windows native addon builds reject delay-import tables the loader cannot use.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Build[Build Windows addon] --> Check[Shared delay-import check]
  Check --> Manifest[Create manifest]
  Source[Source verifier] --> Identity[Check manifest and digest]
  Packed[Packed verifier] --> Identity
  Identity --> Check
  Check --> Accept[Accept artifact]
Loading

Reviews (2) · Last reviewed commit: "fix(windows): validate delay-load descri..." · Reviewed by Greptile

Comment thread src/domain/windowsNativeArtifact.ts Resolved
@greptile-apps

greptile-apps Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

security Security Review

This PR appears safe to merge from a security standpoint.

What was checked
  • The new delay-import gate fails closed: every path that accepts an artifact fully validates the descriptor fields, a writable file-backed slot for every import, the module-handle slot, and the DLL name; a missing or malformed optional header or directory is rejected, not skipped.
  • Every byte read in the new validator is bounded by its own mapping checks, and the name-table walk terminates because unmapped slots stop it, so artifact bytes cannot cause an out-of-file read or an unbounded loop.
  • The manifest digest still binds the artifact before it can load, and the build lane now runs the delay-import check before minting a manifest, so malformed linker output cannot reach publication through either the build or the source-free verifier.
  • The runtime Windows loader path is unchanged: it still verifies the manifest digest and PE identity before loading native code, and the delay-import check is a publication-time control by design.
  • The PR genuinely supersedes the listed prior PRs: their referenced commit is an ancestor of this head, and this version adds stricter checks on top of it, so it is not itself superseded.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-29T03:27:23.674544Z 93eadb4 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.

Copy link
Copy Markdown
Contributor Author

Hi @morluto, could you take another look at this PR when you have a chance? Thank you very much for reviewing it.

Commit 93eadb4d5 addresses the delay-descriptor feedback. The verifier now requires a readable, file-backed, terminated DLL name and a full pointer-width module-handle slot in a writable image section. The slot can be in zero-filled image data. The focused suite passed all three tests, including source and packed verifier cases, and the normal pre-push checks passed. The Windows-hosted workflow is still to be verified for this revision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant