This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Deprecate RC4 ciphers from the default ciphers list #25603
Closed
misterdjules
wants to merge
16
commits into
nodejs:v0.10
from
misterdjules:RC4-not-in-default-ciphers-0-10
Closed
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
cc935a2
tls: disable RC4, add --cipher-list command line switch
jasnell 09e9430
tls: make the --enable-legacy-cipher-list help less verbose
jasnell 1006b28
tls: order of precedence on cipher list options, type checking
jasnell ead952d
test: test-tls-cipher-list test error type
jasnell 8687086
test: fix typo in tls.markdown doc and additional tests
jasnell 0793970
tls: refactor test-tls-cipher-list and v0.10.38 legacy test
jasnell dfead0d
test: additional refinements in the test
jasnell d852445
test: additional round of edits on the test-tls-cipher-list.js
jasnell 014912c
test: refactor default cipher list test
jasnell 1c25456
tls: fix default ciphers not used consistently
56e7970
test: backport fix ssl/tls options matrix test
d7a4ca5
test: update ssl options matrix tests
cebce08
cryto: don't set default ciphers if client uses 10.38 legacy cipher
9783a82
tls,crypto: small refactoring for legacy ciphers
bd74d90
tls,crypto: update default cipher list version numbers
ca77bae
src: fix warnings about cipher lists
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,8 @@ | |
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
// USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
var _crypto = process.binding('crypto'); | ||
|
||
var crypto = require('crypto'); | ||
var util = require('util'); | ||
var net = require('net'); | ||
|
@@ -31,8 +33,9 @@ var constants = require('constants'); | |
|
||
var Timer = process.binding('timer_wrap').Timer; | ||
|
||
var DEFAULT_CIPHERS = 'ECDHE-RSA-AES128-SHA256:AES128-GCM-SHA256:' + // TLS 1.2 | ||
'RC4:HIGH:!MD5:!aNULL:!EDH'; // TLS 1.0 | ||
var DEFAULT_CIPHERS = _crypto.DEFAULT_CIPHER_LIST; | ||
|
||
exports.getLegacyCiphers = _crypto.getLegacyCiphers; | ||
|
||
// Allow {CLIENT_RENEG_LIMIT} client-initiated session renegotiations | ||
// every {CLIENT_RENEG_WINDOW} seconds. An error event is emitted if more | ||
|
@@ -44,7 +47,7 @@ exports.CLIENT_RENEG_WINDOW = 600; | |
exports.SLAB_BUFFER_SIZE = 10 * 1024 * 1024; | ||
|
||
exports.getCiphers = function() { | ||
var names = process.binding('crypto').getSSLCiphers(); | ||
var names = _crypto.getSSLCiphers(); | ||
// Drop all-caps names in favor of their lowercase aliases, | ||
var ctx = {}; | ||
names.forEach(function(name) { | ||
|
@@ -65,7 +68,7 @@ if (process.env.NODE_DEBUG && /tls/.test(process.env.NODE_DEBUG)) { | |
|
||
var Connection = null; | ||
try { | ||
Connection = process.binding('crypto').Connection; | ||
Connection = _crypto.Connection; | ||
} catch (e) { | ||
throw new Error('node.js not compiled with openssl crypto support.'); | ||
} | ||
|
@@ -1335,6 +1338,16 @@ exports.connect = function(/* [port, host], options, cb */) { | |
var defaults = { | ||
rejectUnauthorized: '0' !== process.env.NODE_TLS_REJECT_UNAUTHORIZED | ||
}; | ||
if (!process._usingV1040Ciphers()) { | ||
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. @jasnell I don't think that this change is needed given that we have https://github.com/joyent/node/pull/25603/files#diff-437b078f0e3aa5b13790315b3813fd4fR138 too. Or am I missing something? That would have the nice side effect of not needing to expose |
||
// only set the default ciphers if we are _not_ using the | ||
// v0.10.40 legacy cipher list. Node v0.10.40 had a bug | ||
// that failed to set the default ciphers on the default | ||
// options. This has been fixed in v0.10.39 and above. | ||
// However, when the user explicitly tells node to revert | ||
// back to using the v0.10.40 cipher list, node should | ||
// revert back to the original v0.10.40 behavior. | ||
defaults.ciphers = DEFAULT_CIPHERS; | ||
} | ||
options = util._extend(defaults, options || {}); | ||
|
||
options.secureOptions = crypto._getSecureOptions(options.secureProtocol, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2566,6 +2566,8 @@ static void PrintHelp() { | |
" --max-stack-size=val set max v8 stack size (bytes)\n" | ||
" --enable-ssl2 enable ssl2\n" | ||
" --enable-ssl3 enable ssl3\n" | ||
" --cipher-list=val specify the default TLS cipher list\n" | ||
" --enable-legacy-cipher-list=v0.10.40 \n" | ||
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. Extra space before \n |
||
"\n" | ||
"Environment variables:\n" | ||
#ifdef _WIN32 | ||
|
@@ -2577,6 +2579,8 @@ static void PrintHelp() { | |
"NODE_MODULE_CONTEXTS Set to 1 to load modules in their own\n" | ||
" global contexts.\n" | ||
"NODE_DISABLE_COLORS Set to 1 to disable colors in the REPL\n" | ||
"NODE_CIPHER_LIST Override the default TLS cipher list\n" | ||
"NODE_LEGACY_CIPHER_LIST=v0.10.40\n" | ||
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. Shouldn't the description explain what this does? |
||
"\n" | ||
"Documentation can be found at http://nodejs.org/\n"); | ||
} | ||
|
@@ -2652,6 +2656,18 @@ static void ParseArgs(int argc, char **argv) { | |
} else if (strcmp(arg, "--throw-deprecation") == 0) { | ||
argv[i] = const_cast<char*>(""); | ||
throw_deprecation = true; | ||
} else if (strncmp(arg, "--cipher-list=", 14) == 0) { | ||
DEFAULT_CIPHER_LIST = arg + 14; | ||
argv[i] = const_cast<char*>(""); | ||
} else if (strncmp(arg, "--enable-legacy-cipher-list=", 28) == 0) { | ||
const char * legacy_list = crypto::LegacyCipherList(arg+28); | ||
if (legacy_list != NULL) { | ||
DEFAULT_CIPHER_LIST = legacy_list; | ||
} else { | ||
fprintf(stderr, "Error: An unknown legacy cipher list was specified\n"); | ||
exit(9); | ||
} | ||
argv[i] = const_cast<char*>(""); | ||
} else if (argv[i][0] != '-') { | ||
break; | ||
} | ||
|
@@ -2928,6 +2944,26 @@ char** Init(int argc, char *argv[]) { | |
// Make inherited handles noninheritable. | ||
uv_disable_stdio_inheritance(); | ||
|
||
// set the cipher list from the environment variable first, | ||
// the command line switch will override if specified. | ||
const char * cipher_list = getenv("NODE_CIPHER_LIST"); | ||
if (cipher_list != NULL) { | ||
DEFAULT_CIPHER_LIST = cipher_list; | ||
} | ||
|
||
// Setting NODE_LEGACY_CIPHER_LIST will override the NODE_CIPHER_LIST | ||
const char * leg_cipher_id = getenv("NODE_LEGACY_CIPHER_LIST"); | ||
if (leg_cipher_id != NULL) { | ||
const char * leg_cipher_list = | ||
crypto::LegacyCipherList(leg_cipher_id); | ||
if (leg_cipher_list != NULL) { | ||
DEFAULT_CIPHER_LIST = leg_cipher_list; | ||
} else { | ||
fprintf(stderr, "Error: An unknown legacy cipher list was specified\n"); | ||
exit(9); | ||
} | ||
} | ||
|
||
// Parse a few arguments which are specific to Node. | ||
node::ParseArgs(argc, argv); | ||
// Parse the rest of the args (up to the 'option_end_index' (where '--' was | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jasnell Per #23947 (comment), we could replace this with:
since we said that
null
andundefined
would mean "use the default ciphers list`. That would also mean that the empty string would make node use the empty string unless the v0.10.40 legacy cipher is used, but that also sounds reasonable.