-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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
child_process: check array readability in spawn #56625
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #56625 +/- ##
==========================================
+ Coverage 89.17% 89.20% +0.03%
==========================================
Files 662 663 +1
Lines 191761 192012 +251
Branches 36905 36929 +24
==========================================
+ Hits 171006 171291 +285
+ Misses 13620 13586 -34
Partials 7135 7135
|
872e7ce
to
e9296b7
Compare
lib/internal/child_process.js
Outdated
@@ -247,6 +247,13 @@ function stdioStringToArray(stdio, channel) { | |||
throw new ERR_INVALID_ARG_VALUE('stdio', stdio); | |||
} | |||
|
|||
for (let i = 0; i < options.length; i++) { |
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.
Can you add a comment for future readers? FWIW, I think we should not "fix" this. There are probably other crashes like the one this is fixing if built-in prototypes are modified.
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.
yeah, I had the same thought. Sure I will add a comment.
Edit: leaving this unresolved for more input.
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.
I think a less brittle and easier to understand fix would be to initialize the array with let options;
and then use options = [a, b, c]
instead of ArrayPrototypePush
Failed to start CI⚠ No approving reviews found ✘ Refusing to run CI on potentially unsafe PRhttps://github.com/nodejs/node/actions/runs/12894525741 |
Co-authored-by: Jake Yuesong Li <jake.yuesong@gmail.com>
With previous example issues caused by prototype pollution, I don't think we should add a test, as this PR fixes it from hard crash, but does not guarantee a defined behaviour. For example,
gives
In case we does check if array is readable in some other modules, the error would likely be different.
Fixes: #56531