Wldp integration#63418
Open
rdw-msft wants to merge 2 commits into
Open
Conversation
Add calls to Windows Defender Application Control to enforce integrity of .js, .json, .node files.
Collaborator
|
Review requested:
|
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.
This PR adds experimental Windows-only integration with Windows Defender Application Control (WDAC) so Node.js can participate in OS-managed code integrity enforcement.
Motivation
Node.js's threat model treats the code the runtime is asked to execute as trusted. This change does not alter that threat model or introduce a new Node.js security boundary.
Instead, this adds an opt-in defense-in-depth feature for Windows environments that already use WDAC to control what code may execute on the system. In those deployments, Node.js can cooperate with the operating system's code integrity policy before loading certain files intended for execution.
The goal is to help operators and application authors align Node.js with OS-level integrity policy and reduce the risk of post-deployment tampering of application files.
More specifically, this integration helps users and operators gain stronger assurance that the JavaScript, JSON, and native addon files Node.js loads have not been modified from the version signed and shipped by the application author. In environments that enable this feature, Node.js can ask Windows to validate that code being loaded still matches the integrity metadata established at build or release time and is trusted by system policy.
What is WDAC?
Windows Defender Application Control (WDAC) is a Windows security feature that allows administrators to define code integrity policies for a system. These policies determine which code is trusted to run, using mechanisms such as digital signatures, file hashes, certificates, and related policy configuration.
For traditional binaries like EXEs and DLLs, Windows can usually enforce those checks directly. For dynamic runtimes like Node.js, the operating system cannot always determine whether a file being opened is intended for execution, so the runtime must explicitly cooperate with WDAC.
With this change, Node.js can ask WDAC whether files it is about to load for execution are permitted by policy.
WDAC policies can also provide tamper-resistant application-specific settings. These settings let administrators opt Node.js into code integrity enforcement and optionally disable interactive execution modes such as REPL and
--eval.What this PR does
When WDAC policy enables the Node.js-specific
EnforceCodeIntegritysetting, Node.js consults WDAC before loading:.js.json.nodefiles through the module loaders.
If the WDAC policy indicates that the file is not allowed to execute, Node.js throws
ERR_CODE_INTEGRITY_VIOLATIONinstead of proceeding.When WDAC policy enables
DisableInteractiveMode, Node.js also disables execution paths intended for interactive or ad hoc code entry, including:-e--evalIn those cases Node.js throws
ERR_CODE_INTEGRITY_BLOCKED.If these policy settings are not enabled, behavior is unchanged.
Scope and security model
This feature is Windows-only and disabled by default.
It should be understood as a hardening and policy-enforcement integration for managed environments, not as a general-purpose sandbox or a replacement for application security boundaries.
In particular:
SECURITY.md.Instead, it gives administrators a way to require that code loaded by Node.js comply with WDAC policy when they explicitly opt into that behavior.
WDAC APIs used
This PR uses the following WDAC interfaces:
WldpCanExecuteFileChecks whether a file is allowed to execute under WDAC policy.
WldpGetApplicationSettingBooleanReads Node.js-specific WDAC application settings where supported.
WldpQuerySecurityPolicyProvides fallback policy-setting lookup on older Windows versions.
Audiences
There are two audiences for this feature:
Node.js only performs these checks when WDAC policy is configured to request them.
Signing model
For script and module content that Node.js is expected to execute, application authors can generate a Windows catalog (
.cat) containing file hashes and sign it with a certificate trusted by WDAC policy.This gives operators and end users stronger confidence that the files Node.js executes in production are the same files the application author produced and signed at build or release time, rather than modified copies introduced later.
For example:
The resulting catalog can then be signed using PowerShell or
signtool.exeand deployed according to WDAC guidance.Documentation
User-facing documentation for this feature is added in
doc/api/code_integrity.md.Other Questions
What about Linux?
At the moment, there is no unified code integrity subsystem that provides similar cooperative interfaces for interpreters on Linux. There are proposals in-flight and we're tracking this work and hope to keep the implementation as similar as possible across OSs.
Continued maintenance
We believe this is a valuable security feature and are committed to maintaining it. However, we would like to receive confirmation from the Node.js maintainers that this is a feature that they are willing to adopt before we dedicate more resources to this effort. To that effect, I will not complete this PR until we have confirmed resources on our end (that is, people/teams in addition to myself) to support the feature.
Other references
Official WDAC documentation
WLDP Developer Documentation