Skip to content

Instantly share code, notes, and snippets.

@3rd-Eden
Last active January 4, 2021 10:20
  • Star 24 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Protecting against POODLE in node.js

Google recently announced that there is an exploit in SSLv3, this vulnerability is know as POODLE. There is no other option than to disable SSLv3 in order to combat this major flaw. There have already been guides on how to disable this in different servers. But nothing excised for Node.js yet, until now. In order to resolve this for Node.js we need to use various of undocumented options and modules.

In the index.js file below you can see an example of how you can protect your HTTPS server against the POODLE attack. It uses the secureOptions option to pass in constants in to the SSL context which is created by node.

Start the server locally by running:

sudo node index.js

And see if SSLv3 is correctly disabled by connecting with an openssl client:

openssl s_client -connect 127.0.0.1:443 -ssl3

It should respond with a handshake failure:

CONNECTED(00000003)
47309:error:1409E0E5:SSL routines:SSL3_WRITE_BYTES:ssl handshake failure:/SourceCache/OpenSSL098/OpenSSL098-52/src/ssl/s3_pkt.c:546:

If we connect normally, it will just work:

openssl s_client -connect 127.0.0.1:443
'use strict';
var constants = require('constants')
, https = require('https')
, path = require('path')
, tls = require('tls')
, fs = require('fs');
//
// https and tls support the same createServer options, so it doesn't
// matter which one you create as long as you supply the `secureOptions`
//
https.createServer({
//
// This is the default secureProtocol used by Node.js, but it might be
// sane to specify this by default as it's required if you want to
// remove supported protocols from the list. This protocol supports:
//
// - SSLv2, SSLv3, TLSv1, TLSv1.1 and TLSv1.2
//
secureProtocol: 'SSLv23_method',
//
// Supply `SSL_OP_NO_SSLv3` constant as secureOption to disable SSLv3
// from the list of supported protocols that SSLv23_method supports.
//
secureOptions: constants.SSL_OP_NO_SSLv3,
cert: fs.readFileSync(path.join(__dirname, 'ssl', 'server.crt')),
key: fs.readFileSync(path.join(__dirname, 'ssl', 'server.key')),
}, function (req, res) {
res.end('works');
}).listen(443);
@niczak
Copy link

niczak commented Feb 2, 2015

Ignore my above comment, figured out the problem. We had a method that would post back to another server (in some cases) that was forcing SSLv3. Problem solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment