mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
CVE-2018-12120 Backport of8e7cbe2to v6.x Prepared by Sam Roberts <vieuxtech@gmail.com> Original commit: Commit2272052("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>
46 lines
1.7 KiB
JavaScript
46 lines
1.7 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const spawn = require('child_process').spawn;
|
|
|
|
let run = () => {};
|
|
function test(args, needle) {
|
|
const next = run;
|
|
run = () => {
|
|
const options = {encoding: 'utf8'};
|
|
const proc = spawn(process.execPath, args.concat(['-e', '0']), options);
|
|
let stderr = '';
|
|
proc.stderr.setEncoding('utf8');
|
|
proc.stderr.on('data', (data) => {
|
|
stderr += data;
|
|
if (stderr.includes(needle)) proc.kill();
|
|
});
|
|
proc.on('exit', common.mustCall(() => {
|
|
assert(stderr.includes(needle));
|
|
next();
|
|
}));
|
|
};
|
|
}
|
|
|
|
test(['--debug-brk'], 'Debugger listening on 127.0.0.1:5858');
|
|
test(['--debug-brk=1234'], 'Debugger listening on 127.0.0.1:1234');
|
|
test(['--debug-brk=0.0.0.0'], 'Debugger listening on 0.0.0.0:5858');
|
|
test(['--debug-brk=0.0.0.0:1234'], 'Debugger listening on 0.0.0.0:1234');
|
|
test(['--debug-brk=localhost'], 'Debugger listening on 127.0.0.1:5858');
|
|
test(['--debug-brk=localhost:1234'], 'Debugger listening on 127.0.0.1:1234');
|
|
|
|
if (common.hasIPv6) {
|
|
test(['--debug-brk=::'], 'Debug port must be in range 1024 to 65535');
|
|
test(['--debug-brk=::0'], 'Debug port must be in range 1024 to 65535');
|
|
test(['--debug-brk=::1'], 'Debug port must be in range 1024 to 65535');
|
|
test(['--debug-brk=[::]'], 'Debugger listening on [::]:5858');
|
|
test(['--debug-brk=[::0]'], 'Debugger listening on [::]:5858');
|
|
test(['--debug-brk=[::]:1234'], 'Debugger listening on [::]:1234');
|
|
test(['--debug-brk=[::0]:1234'], 'Debugger listening on [::]:1234');
|
|
test(['--debug-brk=[::ffff:127.0.0.1]:1234'],
|
|
'Debugger listening on [::ffff:127.0.0.1]:1234');
|
|
}
|
|
|
|
run(); // Runs tests in reverse order.
|