-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
lib: add warning when binding inspector to public IP #55736
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
common.skipIfInspectorDisabled(); | ||
|
||
const inspector = require('inspector'); | ||
inspector.open(0, '0.0.0.0', false); | ||
common.expectWarning( | ||
'SecurityWarning', | ||
'Binding the inspector to a public IP with an open port is insecure, ' + | ||
'as it allows external hosts to connect to the inspector ' + | ||
'and perform a remote code execution attack. ' + | ||
'Documentation can be found at ' + | ||
'https://nodejs.org/api/cli.html#--inspecthostport' | ||
); | ||
inspector.close(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Flags: --expose-internals | ||
'use strict'; | ||
require('../common'); | ||
const assert = require('assert'); | ||
const net = require('internal/net'); | ||
|
||
const loopback = [ | ||
'localhost', | ||
'127.0.0.1', | ||
'127.0.0.255', | ||
'127.1.2.3', | ||
'[::1]', | ||
'[0:0:0:0:0:0:0:1]', | ||
]; | ||
|
||
const loopbackNot = [ | ||
'example.com', | ||
'192.168.1.1', | ||
'10.0.0.1', | ||
Comment on lines
+18
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we really warn for these? IMHO binding to IP in private subnet is usually fine. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The condition when to warn was discussed in #23756 (review) and #23756 (comment). So, I think we should warn for all non-loopback addresses. WDYT? |
||
'255.255.255.255', | ||
'[2001:db8::1]', | ||
'[fe80::1]', | ||
'8.8.8.8', | ||
]; | ||
|
||
for (const address of loopback) { | ||
assert.strictEqual(net.isLoopback(address), true); | ||
} | ||
|
||
for (const address of loopbackNot) { | ||
assert.strictEqual(net.isLoopback(address), false); | ||
DemianParkhomenko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
Uh oh!
There was an error while loading. Please reload this page.