Skip to content

Commit bd65f9c

Browse files
author
Shigeki Ohtsu
committed
tls,crypto: remove SSLv2 support
openssl-1.0.1s disables SSLv2 by default for against DROWN attack. There no needs to support SSLv2 in Node.
1 parent fa26b13 commit bd65f9c

11 files changed

Lines changed: 18 additions & 185 deletions

File tree

configure

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,6 @@ parser.add_option('--without-ssl',
313313
dest='without_ssl',
314314
help='build without SSL')
315315

316-
parser.add_option('--without-ssl2',
317-
action='store_true',
318-
dest='ssl2',
319-
help='Disable SSL v2')
320-
321316
parser.add_option('--without-ssl3',
322317
action='store_true',
323318
dest='ssl3',
@@ -687,9 +682,6 @@ def configure_openssl(o):
687682
if options.without_ssl:
688683
return
689684

690-
if options.ssl2:
691-
o['defines'] += ['OPENSSL_NO_SSL2=1']
692-
693685
if options.ssl3:
694686
o['defines'] += ['OPENSSL_NO_SSL3=1']
695687

doc/api/tls.markdown

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,23 @@ To create .pfx or .p12, do this:
4040

4141
## Protocol support
4242

43-
Node.js is compiled with SSLv2 and SSLv3 protocol support by default, but these
43+
Node.js is compiled with SSLv3 protocol support by default, but these
4444
protocols are **disabled**. They are considered insecure and could be easily
4545
compromised as was shown by [CVE-2014-3566][]. However, in some situations, it
4646
may cause problems with legacy clients/servers (such as Internet Explorer 6).
47-
If you wish to enable SSLv2 or SSLv3, run node with the `--enable-ssl2` or
48-
`--enable-ssl3` flag respectively. In future versions of Node.js SSLv2 and
49-
SSLv3 will not be compiled in by default.
47+
If you wish to enable SSLv3, run node with `--enable-ssl3` flag. In
48+
future versions of Node.js SSLv3 will not be compiled in by default.
5049

51-
There is a way to force node into using SSLv3 or SSLv2 only mode by explicitly
52-
specifying `secureProtocol` to `'SSLv3_method'` or `'SSLv2_method'`.
50+
There is a way to force node into using SSLv3 only mode by explicitly
51+
specifying `secureProtocol` to `'SSLv3_method'`.
5352

5453
The default protocol method Node.js uses is `SSLv23_method` which would be more
5554
accurately named `AutoNegotiate_method`. This method will try and negotiate
5655
from the highest level down to whatever the client supports. To provide a
57-
secure default, Node.js (since v0.10.33) explicitly disables the use of SSLv3
58-
and SSLv2 by setting the `secureOptions` to be
59-
`SSL_OP_NO_SSLv3|SSL_OP_NO_SSLv2` (again, unless you have passed
60-
`--enable-ssl3`, or `--enable-ssl2`, or `SSLv3_method` as `secureProtocol`).
56+
secure default, Node.js (since v0.10.33) explicitly disables the use
57+
of SSLv3 by setting the `secureOptions` to be `SSL_OP_NO_SSLv3`
58+
(again, unless you have passed `--enable-ssl3`, or `SSLv3_method` as
59+
`secureProtocol`).
6160

6261
If you have set `secureOptions` to anything, we will not override your
6362
options.
@@ -219,10 +218,6 @@ automatically set as a listener for the [secureConnection][] event. The
219218
use this option in conjunction with the `ciphers` option to mitigate
220219
BEAST attacks.
221220

222-
Note: If SSLv2 is used, the server will send its list of preferences to the
223-
client, and the client chooses the cipher. Support for SSLv2 is disabled
224-
unless node.js was configured with `./configure --with-sslv2`.
225-
226221
- `requestCert`: If `true` the server will request a certificate from
227222
clients that connect and attempt to verify that certificate. Default:
228223
`false`.

doc/node.1

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@ and servers.
6262

6363
--max-stack-size=val set max v8 stack size (bytes)
6464

65-
--enable-ssl2 enable ssl2 in crypto, tls, and https
66-
modules
67-
6865
--enable-ssl3 enable ssl3 in crypto, tls, and https
6966
modules
7067

@@ -113,7 +110,7 @@ If set to 1 then colors will not be used in the REPL.
113110
--crankshaft (use crankshaft)
114111
type: bool default: true
115112
--hydrogen_filter (optimization filter)
116-
type: string default:
113+
type: string default:
117114
--use_range (use hydrogen range analysis)
118115
type: bool default: true
119116
--eliminate_dead_phis (eliminate dead phis)
@@ -391,9 +388,9 @@ If set to 1 then colors will not be used in the REPL.
391388
--debugger_port (Port to use for remote debugging)
392389
type: int default: 5858
393390
--map_counters (Map counters to a file)
394-
type: string default:
391+
type: string default:
395392
--js_arguments (Pass all remaining arguments to the script. Alias for "--".)
396-
type: arguments default:
393+
type: arguments default:
397394
--debug_compile_events (Enable debugger compile events)
398395
type: bool default: true
399396
--debug_script_collected_events (Enable debugger script collected events)
@@ -405,7 +402,7 @@ If set to 1 then colors will not be used in the REPL.
405402
--gdbjit_dump (dump elf objects with debug info to disk)
406403
type: bool default: false
407404
--gdbjit_dump_filter (dump only objects containing this substring)
408-
type: string default:
405+
type: string default:
409406
--force_marking_deque_overflows (force overflows of marking deque by reducing its size to 64 words)
410407
type: bool default: false
411408
--stress_compaction (stress the GC compactor to flush out bugs (implies --force_marking_deque_overflows))

lib/_tls_common.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ function getSecureOptions(secureProtocol, secureOptions) {
3838
if (!binding.SSL3_ENABLE)
3939
CONTEXT_DEFAULT_OPTIONS |= constants.SSL_OP_NO_SSLv3;
4040

41-
if (!binding.SSL2_ENABLE)
42-
CONTEXT_DEFAULT_OPTIONS |= constants.SSL_OP_NO_SSLv2;
4341
}
4442

4543
if (secureOptions === undefined) {

src/node.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3012,7 +3012,6 @@ static void PrintHelp() {
30123012
" present.\n"
30133013
#endif
30143014
#endif
3015-
" --enable-ssl2 enable ssl2\n"
30163015
" --enable-ssl3 enable ssl3\n"
30173016
"\n"
30183017
"Environment variables:\n"
@@ -3081,10 +3080,6 @@ static void ParseArgs(int* argc,
30813080
} else if (strcmp(arg, "--version") == 0 || strcmp(arg, "-v") == 0) {
30823081
printf("%s\n", NODE_VERSION);
30833082
exit(0);
3084-
} else if (strcmp(arg, "--enable-ssl2") == 0) {
3085-
#if HAVE_OPENSSL
3086-
SSL2_ENABLE = true;
3087-
#endif
30883083
} else if (strcmp(arg, "--enable-ssl3") == 0) {
30893084
#if HAVE_OPENSSL
30903085
SSL3_ENABLE = true;

src/node_constants.cc

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -787,10 +787,6 @@ void DefineOpenSSLConstants(Handle<Object> target) {
787787
NODE_DEFINE_CONSTANT(target, SSL_OP_MICROSOFT_SESS_ID_BUG);
788788
#endif
789789

790-
#ifdef SSL_OP_MSIE_SSLV2_RSA_PADDING
791-
NODE_DEFINE_CONSTANT(target, SSL_OP_MSIE_SSLV2_RSA_PADDING);
792-
#endif
793-
794790
#ifdef SSL_OP_NETSCAPE_CA_DN_BUG
795791
NODE_DEFINE_CONSTANT(target, SSL_OP_NETSCAPE_CA_DN_BUG);
796792
#endif
@@ -819,10 +815,6 @@ void DefineOpenSSLConstants(Handle<Object> target) {
819815
NODE_DEFINE_CONSTANT(target, SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION);
820816
#endif
821817

822-
#ifdef SSL_OP_NO_SSLv2
823-
NODE_DEFINE_CONSTANT(target, SSL_OP_NO_SSLv2);
824-
#endif
825-
826818
#ifdef SSL_OP_NO_SSLv3
827819
NODE_DEFINE_CONSTANT(target, SSL_OP_NO_SSLv3);
828820
#endif

src/node_crypto.cc

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ static const int X509_NAME_FLAGS = ASN1_STRFLGS_ESC_CTRL
7575

7676
namespace node {
7777

78-
bool SSL2_ENABLE = false;
7978
bool SSL3_ENABLE = false;
8079
bool ALLOW_INSECURE_SERVER_DHPARAM = false;
8180

@@ -316,25 +315,7 @@ void SecureContext::Init(const FunctionCallbackInfo<Value>& args) {
316315
if (args.Length() == 1 && args[0]->IsString()) {
317316
const node::Utf8Value sslmethod(args[0]);
318317

319-
if (strcmp(*sslmethod, "SSLv2_method") == 0) {
320-
#ifndef OPENSSL_NO_SSL2
321-
method = SSLv2_method();
322-
#else
323-
return env->ThrowError("SSLv2 methods disabled");
324-
#endif
325-
} else if (strcmp(*sslmethod, "SSLv2_server_method") == 0) {
326-
#ifndef OPENSSL_NO_SSL2
327-
method = SSLv2_server_method();
328-
#else
329-
return env->ThrowError("SSLv2 methods disabled");
330-
#endif
331-
} else if (strcmp(*sslmethod, "SSLv2_client_method") == 0) {
332-
#ifndef OPENSSL_NO_SSL2
333-
method = SSLv2_client_method();
334-
#else
335-
return env->ThrowError("SSLv2 methods disabled");
336-
#endif
337-
} else if (strcmp(*sslmethod, "SSLv3_method") == 0) {
318+
if (strcmp(*sslmethod, "SSLv3_method") == 0) {
338319
#ifndef OPENSSL_NO_SSL3
339320
method = SSLv3_method();
340321
#else
@@ -5171,7 +5152,6 @@ void InitCrypto(Handle<Object> target,
51715152
EVP_PKEY_decrypt>);
51725153

51735154
NODE_DEFINE_CONSTANT(target, SSL3_ENABLE);
5174-
NODE_DEFINE_CONSTANT(target, SSL2_ENABLE);
51755155
}
51765156

51775157
} // namespace crypto

src/node_crypto.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161

6262
namespace node {
6363

64-
extern bool SSL2_ENABLE;
6564
extern bool SSL3_ENABLE;
6665
extern bool ALLOW_INSECURE_SERVER_DHPARAM;
6766

src/node_crypto_clienthello.cc

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ void ClientHelloParser::Parse(const uint8_t* data, size_t avail) {
3232
break;
3333
// Fall through
3434
case kTLSHeader:
35-
case kSSL2Header:
3635
ParseHeader(data, avail);
3736
break;
3837
case kPaused:
@@ -59,20 +58,8 @@ bool ClientHelloParser::ParseRecordHeader(const uint8_t* data, size_t avail) {
5958
state_ = kTLSHeader;
6059
body_offset_ = 5;
6160
} else {
62-
#ifdef OPENSSL_NO_SSL2
63-
frame_len_ = ((data[0] << 8) & kSSL2HeaderMask) + data[1];
64-
state_ = kSSL2Header;
65-
if (data[0] & kSSL2TwoByteHeaderBit) {
66-
// header without padding
67-
body_offset_ = 2;
68-
} else {
69-
// header with padding
70-
body_offset_ = 3;
71-
}
72-
#else
7361
End();
7462
return false;
75-
#endif // OPENSSL_NO_SSL2
7663
}
7764

7865
// Sanity check (too big frame, or too small)
@@ -85,12 +72,6 @@ bool ClientHelloParser::ParseRecordHeader(const uint8_t* data, size_t avail) {
8572
return true;
8673
}
8774

88-
#ifdef OPENSSL_NO_SSL2
89-
# define NODE_SSL2_VER_CHECK(buf) false
90-
#else
91-
# define NODE_SSL2_VER_CHECK(buf) ((buf)[0] == 0x00 && (buf)[1] == 0x02)
92-
#endif // OPENSSL_NO_SSL2
93-
9475

9576
void ClientHelloParser::ParseHeader(const uint8_t* data, size_t avail) {
9677
ClientHello hello;
@@ -101,22 +82,14 @@ void ClientHelloParser::ParseHeader(const uint8_t* data, size_t avail) {
10182

10283
// Skip unsupported frames and gather some data from frame
10384
// Check hello protocol version
104-
if (!(data[body_offset_ + 4] == 0x03 && data[body_offset_ + 5] <= 0x03) &&
105-
!NODE_SSL2_VER_CHECK(data + body_offset_ + 4)) {
85+
if (!(data[body_offset_ + 4] == 0x03 && data[body_offset_ + 5] <= 0x03)) {
10686
goto fail;
10787
}
10888

10989
if (data[body_offset_] == kClientHello) {
11090
if (state_ == kTLSHeader) {
11191
if (!ParseTLSClientHello(data, avail))
11292
goto fail;
113-
} else if (state_ == kSSL2Header) {
114-
#ifdef OPENSSL_NO_SSL2
115-
if (!ParseSSL2ClientHello(data, avail))
116-
goto fail;
117-
#else
118-
abort(); // Unreachable
119-
#endif // OPENSSL_NO_SSL2
12093
} else {
12194
// We couldn't get here, but whatever
12295
goto fail;
@@ -145,7 +118,6 @@ void ClientHelloParser::ParseHeader(const uint8_t* data, size_t avail) {
145118
}
146119

147120

148-
#undef NODE_SSL2_VER_CHECK
149121

150122

151123
void ClientHelloParser::ParseExtension(ClientHelloParser::ExtensionType type,
@@ -269,28 +241,4 @@ bool ClientHelloParser::ParseTLSClientHello(const uint8_t* data, size_t avail) {
269241
return true;
270242
}
271243

272-
273-
#ifdef OPENSSL_NO_SSL2
274-
bool ClientHelloParser::ParseSSL2ClientHello(const uint8_t* data,
275-
size_t avail) {
276-
const uint8_t* body;
277-
278-
// Skip header, version
279-
size_t session_offset = body_offset_ + 3;
280-
281-
if (session_offset + 4 < avail) {
282-
body = data + session_offset;
283-
284-
uint16_t ciphers_size = (body[0] << 8) + body[1];
285-
286-
if (body + 4 + ciphers_size < data + avail) {
287-
session_size_ = (body[2] << 8) + body[3];
288-
session_id_ = body + 4 + ciphers_size;
289-
}
290-
}
291-
292-
return true;
293-
}
294-
#endif // OPENSSL_NO_SSL2
295-
296244
} // namespace node

src/node_crypto_clienthello.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ class ClientHelloParser {
8080
inline bool IsEnded() const;
8181

8282
private:
83-
static const uint8_t kSSL2TwoByteHeaderBit = 0x80;
84-
static const uint8_t kSSL2HeaderMask = 0x3f;
8583
static const size_t kMaxTLSFrameLen = 16 * 1024 + 5;
8684
static const size_t kMaxSSLExFrameLen = 32 * 1024;
8785
static const uint8_t kServernameHostname = 0;
@@ -91,7 +89,6 @@ class ClientHelloParser {
9189
enum ParseState {
9290
kWaiting,
9391
kTLSHeader,
94-
kSSL2Header,
9592
kPaused,
9693
kEnded
9794
};
@@ -120,9 +117,6 @@ class ClientHelloParser {
120117
const uint8_t* data,
121118
size_t len);
122119
bool ParseTLSClientHello(const uint8_t* data, size_t avail);
123-
#ifdef OPENSSL_NO_SSL2
124-
bool ParseSSL2ClientHello(const uint8_t* data, size_t avail);
125-
#endif // OPENSSL_NO_SSL2
126120

127121
ParseState state_;
128122
OnHelloCb onhello_cb_;

0 commit comments

Comments
 (0)