Files
node/test/sequential/test-debug-port-cluster.js
Ben Noordhuis a9791c9090 src: make debugger listen on 127.0.0.1 by default
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>
2018-11-24 16:46:43 +11:00

32 lines
829 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const spawn = require('child_process').spawn;
const PORT_MIN = common.PORT + 1; // The fixture uses common.PORT.
const PORT_MAX = PORT_MIN + 2;
const args = [
'--debug=' + PORT_MIN,
common.fixturesDir + '/clustered-server/app.js'
];
const child = spawn(process.execPath, args);
child.stderr.setEncoding('utf8');
const checkMessages = common.mustCall(() => {
for (let port = PORT_MIN; port <= PORT_MAX; port += 1) {
assert(stderr.includes(`Debugger listening on 127.0.0.1:${port}`));
}
});
let stderr = '';
child.stderr.on('data', (data) => {
process.stderr.write(`[DATA] ${data}`);
stderr += data;
if (child.killed !== true && stderr.includes('all workers are running')) {
child.kill();
checkMessages();
}
});