mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
CVE-2018-12120
Backport of 8e7cbe2 to v6.x
Prepared by Sam Roberts <vieuxtech@gmail.com>
Original commit:
Commit 2272052 ("net: bind to `::` TCP address by default") from
April 2014 seems to have accidentally changed the default listen
address from 127.0.0.1 to 0.0.0.0, a.k.a. the "any" address.
From a security viewpoint it's undesirable to accept debug agent
connections from anywhere so let's change that back. Users can
override the default with the `--debug=<host>:<port>` switch.
Fixes: https://github.com/nodejs/node/issues/8081
PR-URL: https://github.com/nodejs/node/pull/8106
Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs-private/node-private/pull/148
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
82 lines
2.1 KiB
JavaScript
82 lines
2.1 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const spawn = require('child_process').spawn;
|
|
const path = require('path');
|
|
|
|
const port = common.PORT;
|
|
const serverPath = path.join(common.fixturesDir, 'clustered-server', 'app.js');
|
|
const args = [`--debug-port=${port}`, serverPath];
|
|
const options = { stdio: ['inherit', 'inherit', 'pipe', 'ipc'] };
|
|
const child = spawn(process.execPath, args, options);
|
|
|
|
const outputLines = [];
|
|
let waitingForDebuggers = false;
|
|
|
|
let pids;
|
|
|
|
child.stderr.on('data', function(data) {
|
|
const lines = data.toString().replace(/\r/g, '').trim().split('\n');
|
|
|
|
lines.forEach(function(line) {
|
|
console.log('> ' + line);
|
|
|
|
if (line === 'all workers are running') {
|
|
child.on('message', function(msg) {
|
|
if (msg.type !== 'pids')
|
|
return;
|
|
|
|
pids = msg.pids;
|
|
console.error('got pids %j', pids);
|
|
|
|
waitingForDebuggers = true;
|
|
process._debugProcess(child.pid);
|
|
});
|
|
|
|
child.send({
|
|
type: 'getpids'
|
|
});
|
|
} else if (waitingForDebuggers) {
|
|
outputLines.push(line);
|
|
}
|
|
|
|
});
|
|
if (outputLines.length === expectedLines.length)
|
|
onNoMoreLines();
|
|
});
|
|
|
|
function onNoMoreLines() {
|
|
assertOutputLines();
|
|
process.exit();
|
|
}
|
|
|
|
process.on('exit', function onExit() {
|
|
// Kill processes in reverse order to avoid timing problems on Windows where
|
|
// the parent process is killed before the children.
|
|
pids.reverse().forEach(function(pid) {
|
|
process.kill(pid);
|
|
});
|
|
});
|
|
|
|
const expectedLines = [
|
|
'Starting debugger agent.',
|
|
'Debugger listening on 127.0.0.1:' + (port + 0),
|
|
'Starting debugger agent.',
|
|
'Debugger listening on 127.0.0.1:' + (port + 1),
|
|
'Starting debugger agent.',
|
|
'Debugger listening on 127.0.0.1:' + (port + 2),
|
|
];
|
|
|
|
function assertOutputLines() {
|
|
// Do not assume any particular order of output messages,
|
|
// since workers can take different amout of time to
|
|
// start up
|
|
outputLines.sort();
|
|
expectedLines.sort();
|
|
|
|
assert.strictEqual(outputLines.length, expectedLines.length);
|
|
for (let i = 0; i < expectedLines.length; i++)
|
|
assert(expectedLines[i].includes(outputLines[i]));
|
|
}
|