-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Closed
Labels
child_processIssues and PRs related to the child_process subsystem.Issues and PRs related to the child_process subsystem.
Description
- Version:
- Platform:
- Subsystem:
Similar to #9820, the underlying binding code that is used by spawnSync can
segfault when called with objects/array that have "evil" getters/setters. The
following code shows an example of this:
const spawn_sync = process.binding('spawn_sync');
// compute envPairs as done by child_process
let envPairs = [];
for (var key in process.env) {
envPairs.push(key + '=' + process.env[key]);
}
// mess with args
const args = [ '-a' ];
Object.defineProperty(args, 1, {
get: () => {
return 3; // causes StringBytes::Write in spawn_sync.cc:986 to segfault since it's not a string
},
set: () => {
// override so Set after Clone will do nothing because of this
},
enumerable: true
});
const options = {
file: 'ls',
args: args,
envPairs: envPairs,
stdio: [
{ type: 'pipe', readable: true, writable: false },
{ type: 'pipe', readable: false, writable: true },
{ type: 'pipe', readable: false, writable: true }
]
};
spawn_sync.spawn(options);May be worth again ensuring that all arguments are strings before calling into
the binding code.
- @mlfbrown for working on this with me.
Metadata
Metadata
Assignees
Labels
child_processIssues and PRs related to the child_process subsystem.Issues and PRs related to the child_process subsystem.