-
Notifications
You must be signed in to change notification settings - Fork 16.9k
fix: ignore all NODE_ envs from foreign parent in node process #40770
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
Conversation
32bb1aa to
a2f638a
Compare
deepak1556
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
| auto os_env = base::Environment::Create(); | ||
| bool node_options_enabled = electron::fuses::IsNodeOptionsEnabled(); | ||
| if (!node_options_enabled) { | ||
| os_env->UnSetVar("NODE_OPTIONS"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Node already has kDisableNodeOptionsEnv, which we enable. It seems like a Node bug that there are workarounds for this? Can we fix this in Node?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kDisableNodeOptionsEnv means disabling the NODE_OPTIONS env, it is probably arguable whether it should disable other envs too, but anyway I'll bring this up to Node and will patch upstream if they agree so.
In the long term I think what we really need is a way to guarantee there is no way to inject code into an app, but I don't have a good idea how to implement it. I'll discuss with Node team too.
19d1079 to
d567a54
Compare
|
If no opposition I would like to merge this before fixing the upstream Node, since the protection introduced by #40579 is half-baked now, and this change only affects people who do things like |
|
Release Notes Persisted
|
|
I was unable to backport this PR to "26-x-y" cleanly; |
|
I have automatically backported this PR to "27-x-y", please check out #40879 |
|
I have automatically backported this PR to "28-x-y", please check out #40880 |
|
I have automatically backported this PR to "29-x-y", please check out #40881 |
Fixes microsoft#204005 Electron will log a warning when it is launched with these options, see electron/electron#40770 for more context.
Description of Change
This is a followup to #40579.
@deepak1556 found that it is possible to work around the protection of
NODE_OPTIONSby using another envNODE_REPL_EXTERNAL_MODULE, we think it is better just removing all envs start withNODE_in case there are new creative ways invented to work around the protection.Note that
NODE_REPL_EXTERNAL_MODULEonly works in repl mode so only theELECTRON_RUN_AS_NODEprocesses are affected.Checklist
npm testpassesRelease Notes
Notes: Unset all Node envs in node process when parent is a foreign process.