-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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 ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #56625 +/- ##
==========================================
+ Coverage 89.17% 89.20% +0.03%
==========================================
Files 662 662
Lines 191761 191901 +140
Branches 36905 36937 +32
==========================================
+ Hits 171006 171194 +188
+ Misses 13620 13546 -74
- Partials 7135 7161 +26
|
Co-authored-by: Jake Yuesong Li <[email protected]>
@@ -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 |
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