Open D4V3M0NK opened 3 years ago
It is possible to dynamically link against OpenSSL as long as it is a compatible OpenSSL version. We currently use OpenSSL 1.1.1 only, which does not have FIPS certification. The next OpenSSL build with FIPS certification will likely be 3.x, so it is going to be a while longer. I don't think it's realistic to link current Node.js versions against OpenSSL older than 1.1.1.
@tniessen thanks for the feedback, especially your comments that OpenSSL 1.1.1 can be used - and that's exactly the version that I'm looking for. My question is: how do you build with that FIPS support, considering the documentation states that it's not an option?
@tniessen thanks for the feedback, especially your comments that OpenSSL 1.1.1 can be used - and that's exactly the version that I'm looking for. My question is: how do you build with that FIPS support, considering the documentation states that it's not an option?
https://github.com/nodejs/build/issues/2176 has the steps to build for UBI 8.1.
There's also https://github.com/nodejs/node/pull/36341 which aims to rework some of this.
Finally managed to carve out some time to test this. I'm moving forward cautiously as I don't want to mess anything up, but I guess I managed to fall at the first hurdle, attempting this on Ubuntu 18.04LTS:
$ lsb_release -d && uname -r && cat /proc/sys/crypto/fips_enabled && openssl version
Description: Ubuntu 18.04.5 LTS
4.15.0-1052-fips
1
OpenSSL 1.1.1 11 Sep 2018
$ sudo apt install -y build-essential libssl-dev curl git-core clang
$ git clone https://github.com/nodejs/node.git
$ cd node
$ export OPENSSL_ENABLE_MD5_VERIFY=true
$ ./configure --shared-openssl --shared-openssl-includes=/usr/include/openssl --openssl-is-fips
Traceback (most recent call last):
File "./configure", line 21, in <module>
from distutils.spawn import find_executable
ModuleNotFoundError: No module named 'distutils.spawn'
Am I trying this too early? From https://github.com/nodejs/build/issues/2176 it discusses the use of a UBI, but that's appears to be using RedHat which I don't have access to.
Can anyone provide some insight for me please?
See https://github.com/nodejs/node/issues/30189 for the ModuleNotFoundError: No module named 'distutils.spawn'
error.
UBI is a container (for use in e.g. docker, podman) and doesn't require a RHEL subscription to use.
@richardlau thank you for the pointer (and so quickly) ... I'm make
ing at the moment...
So I've tried this with three branches of node (latest, v14.x and v12.x) and I'm failing on what appears to be the https://github.com/nodejs/node/issues/35213 issue. @mscdex states that the version of OpenSSL to be used has to be the same, or newer, than the version bundled with node, stating that v14.x uses v1.1.1. I do have that version (1.1.1-1ubuntu2.fips.2.1~18.04.7.1
) and yet I'm still getting caught. At the very least, v12.x should work shouldn't it?
I have this all scripted and working using the shared (certified) library in Ubuntu 16.04 / OpenSSL 1.0.2g but I also had to amend node_version.h
's NODE_VERSION_IS_RELEASE from 0
to 1
which I've tested with latest, v14.x and v12.x but it still doesn't get me any further.
I feel as if I'm incredibly close, but just can't get over this last hurdle?
As a follow up to this, I was posed a question this evening and it sparked a separate thought.
If I have a system that has a FIPS compliant OpenSSL module installed upon it and running in FIPS mode, then install NodeJS (which obviously comes with it's own OpenSSL libraries), NodeJS wouldn't be FIPS compliant. However, now that everything is installed on the system, is there any way of altering the running config of NodeJS to use the FIPS module available, rather than those it came with?
I've always assumed that one had to build NodeJS linking to that external library, but you know what they say about "assume" ... :)
I know this is long after your question, but just came across this issue.
You can't alter the community Node.js binaries to use the dynamic link library, as you mention you have to rebuild.
Not sure what system you are running on but if it is RHEL, then the RHEL Node.js rpms that you can install already do exactly what you were suggesting -> link against the shared openssl on the RHEL system whichi is FIPs certified.
And having said that I believe it may be changing with OpenSSL 3 in 18.x. In that case it may be possible to configured FIPs providers with the existing binary. @richardlau may have more specific info.
Can we enable FIPS in NodeJS 18 using crypto.setFips, without building NodeJS?
Can we enable FIPS in NodeJS 18 using crypto.setFips, without building NodeJS?
It will get enabled but throws errors for me. I believe that you still have to build from source, but the cool part is that it is FIPS validated due to OpenSSL 3, just you have to build your own runtime bins :-/
I've opened a pull request to update the Node.js documentation for enabling FIPS support with OpenSSL 3: https://github.com/nodejs/node/pull/48194
The short answer is that you do not need to rebuild Node.js 18 or later from source, you can use the binaries from nodejs.org. You will however need the OpenSSL 3 FIPS provider, which you will have to obtain separately.
Is your feature request related to a problem? Please describe. A number of applications that could be FIPS 140-2 compliant simply can't be because the last version of NodeJS that supports being built with certified OpenSSL libraries was v8.x (using the 1.02g libraries). Although I can't find it, I had read a couple of years ago that there was strong consideration of NodeJS v13 being able to be either certified or compliant, but all of the searching that I've done hasn't come up with any mention of that (or any later version) having that capability.
As stated, I'm already using NodeJS v8 in order to run applications that require NodeJS, and so far that has worked out remarkably well considering the age of v8: even newer changes to the upper stack of applications appear to run just fine on this long in the tooth version. However, of course v8 has a number of CVEs that have been addressed in latter versions: but those latter versions can't be compiled using the OpenSSL 1.02g libraries. Added to this is the fact that 1.02g doesn't support TLS1.2+ and with modern browsers no longer supporting TLS1.0/1.1 from March 2021 ... you can see the predicament.
Describe the solution you'd like I'm not a programmer first and foremost, but I've assisted other projects in the same sort of vein, and that is: if I'm running an OS that has gone through FIPS 140-2 certification of the OpenSSL libraries, those other projects have altered their build scripts to be able to compile by linking to the existing libraries already on the system, thereby making their project FIPS compliant. To maintain certification, the OpenSSL libraries can't be re-compiled when on a host, but a program's build script that can be adjusted to compile using those libraries, can be classed as compliant. I'm sure you're aware, the distinction between certified and compliant is significant: the former one has to pony up the finances and go through months worth of work, testing and validation; the latter is free and only (?!) requires the work of altering the build script of the project in question.
Describe alternatives you've considered Are there alternatives to NodeJS? ;) Seriously though, NodeJS has such a solid base and it's reliability is (IMHO) unchallenged, there really isn't another alternative.
For my upper stack of applications I could simply use a newer version of NodeJS, but then they wouldn't be FIPS compliant and that restricts me considerably. I spent months (literally) working through all the versions of NodeJS until I got to the version that could be compiled with the OpenSSL libraries making NodeJS compliant, but AFAIK v8.x was the last version that had this capability. I would love to be told that there's a latter version that can also be used, but I don't believe that to be the case.
FWIW, I'm currently using Ubuntu 16 with the 1.02g OpenSSL libraries but due to the security issues (CVEs etc) I have to look for an alternative. I would love to use Ubuntu 18 and the set of OpenSSL v1.1.1 libraries that Canonical have certified under their Advantage program...
I appreciate the time spent reading through all of this - and keenly look forward to (hopefully good?) news regarding this.
Thank you.