Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(node): Prevent node:child_process from always inheriting the parent environment (#27343) #27340

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

TateKennington
Copy link

@TateKennington TateKennington commented Dec 12, 2024

Fixes #27343

Currently the node:child_process polyfill is always passing the full parent environment to all spawned subprocesses. In the case where options.env is provided those keys are overridden but the rest of the parent environment is still passed through.

On Node the behaviour is for child processes to only inherit the parent environment when options.env isn't specified. When options.env is specified the child process inherits only those keys.

This PR updates the internal node child_process polyfill so that the clearEnv argument is set to true when spawning the subprocess to prevent the parent environment always being inherited by default. It also fixes an issue where normalizeSpawnArguments wasn't returning the env option if options.env was unset.

@CLAassistant
Copy link

CLAassistant commented Dec 12, 2024

CLA assistant check
All committers have signed the CLA.

@TateKennington TateKennington changed the title fix(node): Prevent node:child_process from always inheriting the parent environment fix(node): Prevent node:child_process from always inheriting the parent environment (#27343) Dec 12, 2024
@TateKennington TateKennington marked this pull request as ready for review December 12, 2024 19:34
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.

node:child_process always inherits parent env variables
2 participants