Report information
The Basics
Id:
46764
Status:
open
Priority:
Medium/Medium
Queue:

BugTracker
Version Fixed:
(no value)
Version Found:
(no value)
Versions Affected:
(no value)
Versions Planned:
(no value)
Priority:
(no value)
Severity:
(no value)
CVSS Score:
(no value)
CVE ID:
(no value)
Component:
(no value)
Area:
bug

Dates
Created:Mon, 04 Dec 2017 04:54:18 -0500
Updated:Fri, 09 Mar 2018 08:47:59 -0500
Closed:Not set



This bug tracker is no longer active.

Please go to our Gitlab to submit issues (both feature requests and bug reports) for active projects maintained by Internet Systems Consortium (ISC).

Due to security and confidentiality requirements, full access is limited to the primary maintainers.

Date: Mon, 04 Dec 2017 09:54:18 +0000
Subject: check MD5 and SHA1 support at startup
From: Francis_Dupont@isc.org
To: bind9-confidential@isc.org
To answer to issues like #46746 I propose to add a code in the startup of named which checks if MD5 (when not disabled at build time) and SHA1 is correctly statically supported. The real questions are: - should this be extended to more things? - should the be implemented by adding a new method to dst_func?
Could you please clarify: a) whether this would disallow running BIND compiled with native-pkcs11 option on FIPS mode system with disabled MD5 and SHA1 functions? b) if the answer for a) is yes, whether there's a way how to compile BIND to be operational on such system c) whether there's a way how to compile BIND to adhere to FIPS mode on such system d) why is the startup check better solution than correctly checking for exit codes from the respective functions. There might be temporary errors from HSMs (f.e. network split when using Networked HSM) and that MUST not make BIND to crash.
I've added the new _check functions to libisc.def.in. I also edited some comments for grammar and clarity. Okay to commit.
BTW on Fedora 27 with OPENSSL_FORCE_FIPS_MODE set to 1 in the environment (easier than to boot in FIPS mode): ./named -g -c /dev/null 24-Dec-2017 15:17:29.432 starting BIND 9.12.0rc1 <id:unset_id> 24-Dec-2017 15:17:29.432 running on Linux x86_64 4.14.7-300.fc27.x86_64 #1 SMP Mon Dec 18 16:06:12 UTC 2017 24-Dec-2017 15:17:29.432 built with '--enable-full-report' '--enable-developer' 24-Dec-2017 15:17:29.432 running as: named -g -c /dev/null 24-Dec-2017 15:17:29.432 ---------------------------------------------------- 24-Dec-2017 15:17:29.432 BIND 9 is maintained by Internet Systems Consortium, 24-Dec-2017 15:17:29.432 Inc. (ISC), a non-profit 501(c)(3) public-benefit 24-Dec-2017 15:17:29.432 corporation. Support and training for BIND 9 are 24-Dec-2017 15:17:29.432 available at https://www.isc.org/support 24-Dec-2017 15:17:29.432 ---------------------------------------------------- 24-Dec-2017 15:17:29.432 found 2 CPUs, using 2 worker threads 24-Dec-2017 15:17:29.432 using 1 UDP listener per interface 24-Dec-2017 15:17:29.432 using up to 4096 sockets 24-Dec-2017 15:17:29.433 md5.c:58: fatal error: 24-Dec-2017 15:17:29.433 RUNTIME_CHECK(EVP_DigestInit(ctx->ctx, EVP_md5()) == 1) failed 24-Dec-2017 15:17:29.433 exiting (due to fatal error in library) Abort (core dumped) a side bin9 branch rt46724 built with MD5 disabled (*) works well. (*) "#define PK11_MD5_DISABLE" in lib/isc/include/pk11/site.h
From: "Mukund Sivaraman" <muks@isc.org>
Subject: Re: [ISC-Bugs #46764] check MD5 and SHA1 support at startup
To: "Francis Dupont via RT" <bind9-confidential@isc.org>
Date: Sun, 24 Dec 2017 19:59:07 +0530
On Sun, Dec 24, 2017 at 02:21:58PM +0000, Francis Dupont via RT wrote: > BTW on Fedora 27 with OPENSSL_FORCE_FIPS_MODE set to 1 > in the environment (easier than to boot in FIPS mode): > > ./named -g -c /dev/null > 24-Dec-2017 15:17:29.432 starting BIND 9.12.0rc1 <id:unset_id> > 24-Dec-2017 15:17:29.432 running on Linux x86_64 4.14.7-300.fc27.x86_64 #1 SMP Mon Dec 18 16:06:12 UTC 2017 > 24-Dec-2017 15:17:29.432 built with '--enable-full-report' '--enable-developer' > 24-Dec-2017 15:17:29.432 running as: named -g -c /dev/null > 24-Dec-2017 15:17:29.432 ---------------------------------------------------- > 24-Dec-2017 15:17:29.432 BIND 9 is maintained by Internet Systems Consortium, > 24-Dec-2017 15:17:29.432 Inc. (ISC), a non-profit 501(c)(3) public-benefit > 24-Dec-2017 15:17:29.432 corporation. Support and training for BIND 9 are > 24-Dec-2017 15:17:29.432 available at https://www.isc.org/support > 24-Dec-2017 15:17:29.432 ---------------------------------------------------- > 24-Dec-2017 15:17:29.432 found 2 CPUs, using 2 worker threads > 24-Dec-2017 15:17:29.432 using 1 UDP listener per interface > 24-Dec-2017 15:17:29.432 using up to 4096 sockets > 24-Dec-2017 15:17:29.433 md5.c:58: fatal error: > 24-Dec-2017 15:17:29.433 RUNTIME_CHECK(EVP_DigestInit(ctx->ctx, EVP_md5()) == 1) failed > 24-Dec-2017 15:17:29.433 exiting (due to fatal error in library) > Abort (core dumped) I recommend printing a user-friendly message than the above when EVP_md5() cannot be used, i.e., print an explanation message than using RUNTIME_CHECK(). Mukund
This looks okay to me. I revised the grammar in the FIPS mode message and also added a human-readable error message when EVP_DigestInit() fails for MD5 or SHA*.
On Tue Jan 16 08:50:08 2018, ondrej wrote: > So, here's an idea. > > Instead of exiting on start, when MD5 can't be used, the flag would be > set, and the code that is currently wrapped inside PK11_MD5_DISABLE > would be changed to use this flag. > > The change would be still massive, but no API would be changed and > henceforth: => It does not fit well in the architecture because it supposed a new global state and: 1- there is an embargo about new features and this is one 2- it is in strong opposition with the idea of FIPS mode: when you are in FIPS mode you want a strong guarantee only the FIPS approved crypto can be used. This is why from the beginning FIPS support was associated with disabling MD5 at build time. > a) BIND would be able to run on FIPS-only enabled systems without MD5 => it is but I disagree about your interpretation of why people set the FIPS mode. > b) The change would be backportable to maintenance releases (as no > change in API) => current change will merged as soon as someone confirms me there is no code freeze... (so I give the ticket to Evan). BTW I'd like to resume the old FIPS mode ticket. It assumes OpenSSL FIPS module when now you have RedHat & co too so if the API is common FIPS mode management must be more flexible. And of course we no longer need to wait for a formal request for it as it is available in at least 3 different Linuxes without the incredible burden to build the OpenSSL FIPS module...
You are too buried in your world view. The proposed change won't work for Redhat and they would have to patch the BIND anyway, because the packagers need a single binary that would work on normal and FIPS-only system. So, unless you have a solution that would actually work for these guys maybe you should stop throwing monkey wrenches into the works and come up with a solution that would be actually useful instead of proposing what other people want. The whole crypto API is broken if it cannot catch the errors from the crypto library, but the change to do so would be too intrusive, so we need to come up with a solution that would work for those people instead of yelling "this is wrong". That's not helpful to ISC and definitely not helpful to RedHat or other packagers.
Date: Tue, 16 Jan 2018 17:40:37 +0000
CC:
Subject: Re: [ISC-Bugs #46764] check MD5 and SHA1 support at startup
To: "Francis Dupont via RT" <bind9-confidential@isc.org>
From: "Evan Hunt" <each@isc.org>
> => current change will merged as soon as someone confirms me > there is no code freeze... (so I give the ticket to Evan). It can be merged. The branch that's frozen is v9_12_0_patch, from which 9.12.0 will be built. Master, v9_12, v9_11, etc, are all okay.
> Please close the ticket if no further work is required. Since this was merged into public codebase, I am moving this to public queue and adding Petr Menšík as a Requestor as he was the initiator of the original bug report. Petr could you please look at the proposed solution and comment on that?
Subject: Re: [ISC-Bugs #46764] check MD5 and SHA1 support at startup
Date: Wed, 17 Jan 2018 21:36:46 +0100
CC: "Tomas Hozza" <thozza@redhat.com>
From: "Petr Menšík" <pemensik@redhat.com>
To: bind9-public@isc.org, fdupont@isc.org
Thank you Ondrej. Hello Francis, Hello Evan. Unfortunately I am not happy with this fix at all. It completely missed our intention and actually moved us even farther from solving our issue. I would start with clarification what is our problem. Red Hat supports running in FIPS mode, where only crypto libraries change based on runtime control. It is not required to install FIPS enabled system from customized image. It is not required to maintain one FIPS version of BIND and one non-FIPS. Support for that is built-in into the software and core libraries. How it is enabled on Red Hat Enterprise Linux is at manual page [1]. Our requirement is that all applications should work with all supported digest algorithms in normal mode. That includes MD5 in BIND. Any HMAC algorithm including HMAC-MD5 has to be supported in this mode. Once FIPS mode is enabled in target system, crypto library disables support for MD5. Any try to use md5 will result in error. That is clear I think. In the current code such use would generate fatal error and program would abort. Of course we want to prevent that. But we do not want to prevent starting BIND in FIPS mode. We want to be able to run named the same way like in normal mode. Only difference we would like archieve behavior similar to defined PK11_MD5_DISABLE in pk11/site.h. That means any request to use MD5 will fail like it was not supported at all. When I say fail, I mean single failed request, without crashing or terminating whole daemon. It would be nice if it prevented start with configuration containing MD5 key when MD5 is not available. But we want to be able process any other requests signed by different enabled algorithms. If only HMAC-SHA256 key is used in configuration, named has to start like usual. Because we support older version 9.9 which does not contain different than HMAC-MD5 rndc key support, we cannot remove whole support from the build. I would backport support for more secure algorithms into it. Removing support for the only single algorithm supported before would cause too much confusion. Increase chance of upgrade failures. That is why disabling MD5 in whole build is not option for us. We want to remove its support only in FIPS mode. If that is named or named-pkcs11 variant is not important. We want single build able to support and not support MD5 calls, depending on runtime detection and/or configuration only. The most simple way seems to be changing PK11_MD5_DISABLE define to variable or function, that would be initialized once after start. Instead of conditional compilation, conditional branches would be used. I think it is important to mention, I am not asking you to make it all for me or Red Hat. I am looking for a way to make it maintainable for us. That usually means find a solution that you consider good enough to inclusion into the code base. Now or later. Or at least most of it. Current RT #46764 patch committed with id 614d838acf4e4b61523a044fde014d8ee7f60e70 would not help us. In fact, we would have to revert that in our code to support FIPS mode. I am sorry I was not clear enough from the start. This patch would prevent us starting named in FIPS mode. We want it possible. Our current workaround is to disable control channel using "controls {};" in named.conf. With this patch, it would not even start. We would like failure on the start only when MD5 algorithm was requested in configuration. In all other cases, we want it to start. We would like to use --with-openssl-hash in the future. Our current problem is with --enable-native-pkcs11 variant. But purpose of FIPS mode is to move all hashing functions into certified libraries, out from end applications code. That way we can avoid certification of every single application we provide. We would use --with-openssl-hash to do that. We cannot change it until it can reject MD5 without fatal errors. [1] https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/security_guide/chap-federal_standards_and_regulations#sec-Enabling-FIPS-Mode On 01/17/2018 08:23 PM, Ondrej Sury via RT wrote: >> Please close the ticket if no further work is required. > > Since this was merged into public codebase, I am moving this to public queue and adding Petr Menšík as a Requestor as he was the initiator of the original bug report. > > Petr could you please look at the proposed solution and comment on that? > -- Petr Menšík Software Engineer Red Hat, http://www.redhat.com/ email: pemensik@redhat.com PGP: 65C6C973
On Wed Jan 17 20:37:01 2018, pemensik@redhat.com wrote: > Thank you Ondrej. Hello Francis, Hello Evan. > > Unfortunately I am not happy with this fix at all. It completely > missed > our intention and actually moved us even farther from solving our > issue. => my interpretation of the FIPS mode according to the Guidance document is that in FIPS mode not-approved crypto must not be used and this applies to applications ("user" in FIPS terms) too. So I can see 3 different solutions, none perfect of course: 1- build one bind package with MD5, DSA and DH disabled (DSA because it uses old and unsafe parameters, DH for the same reason and because its only usage implies MD5). It should work well in both FIPS mode enabled or disabled, the only obvious drawback is it does not work (in fact it impossible to configure) with TSIG HMAC-MD5. Note command usages are updated too so attempts to use MD5 raise understandable errors. I don't consider old rndc versions because rndc should come with named and do not accept old configs using MD5 at both sides is IMHO a good thing as soon as error messages are clear about the problem. 2- build two packages. 3- Disable FIPS mode when MD5 is enabled at initialization time, or build bind with internal MD5 code. In both case they make bind behaves as without FIPS but I am not a big fan of them because they clearly defeat the FIPS mode idea. > Once FIPS mode is enabled in target system, crypto library disables > support for MD5. Any try to use md5 will result in error. => it does not make sense: either MD5 is supported or it is not. > Only difference we would like archieve behavior similar to defined > PK11_MD5_DISABLE in pk11/site.h. => the PK11_MD5_DISABLE feature comes from an old (2008) ticket opened by Adam Tkac from Red Hat about FIPS mode support. At that time the FIPS code was the OpenSSL FIPS object module and it was clear that a bind using it should not have MD5 support. It was never released but it leads to remove first MD5 dependencies and after defaults. When HSMs without MD5 support appeared the site.h file was added to allows them to be used. For different reasons, for instance recommendations of early OpenSSL FIPS guides, it was chosen to disable MD5 by an option at build time. BTW it provides a strong guarantee that MD5 code cannot be called: as it is not in the binary it is not reachable. Of course you can object that it is to make security before usability... If you have an usage for it the -P flag was reserved in all command arguments at that time for switching to FIPS mode per application. > That means any request to use MD5 will fail like it was > not supported at all. => note this applies to configuration / command line arguments, etc, not to the MD5 low level crypto. Or with other words the PK11_MD5_DISABLE approach is the right one and your concern is it is a built time vs. run time. > Because we support older version 9.9 which does not contain different > than HMAC-MD5 rndc key support, we cannot remove whole support from > the build. => argh! Partially my fault as I was late to convince my colleagues to go far from MD5. As far as I know 9.9 is EOL in June. > Current RT #46764 patch committed with id > 614d838acf4e4b61523a044fde014d8ee7f60e70 would not help us. In fact, > we > would have to revert that in our code to support FIPS mode. => it is in #ifndef PK11_MD5_DISABLE code so anyway you have to address it. IMHO you should keep it downgrading to a sanity check: if it is reached something went really wrong before. And it includes better error messages. > I am sorry I was not clear enough from the start. This patch would > prevent us starting named in FIPS mode. => prevent to start a named (or any command using crypto) which wants to freely use MD5. > We would like to use --with-openssl-hash in the future. => BTW another heritage of the old FIPS mode work with in addition the fact that OpenSSL is clearly faster (visible different with NSEC3 iterated hash). It was recently made the default when bind is built with OpenSSL. > Our current > problem is with --enable-native-pkcs11 variant. => as no HSM implements a consistent subset of PKCS#11 I am afraid the idea of to provide a bind package with native PKCS#11 will never work. BTW only SoftHSMv2 with OpenSSL backend (and not in FIPS mode) can run all the system tests...
CC: "Tomas Hozza" <thozza@redhat.com>
Date: Thu, 18 Jan 2018 13:14:22 +0100
From: "Petr Menšík" <pemensik@redhat.com>
Subject: Re: [ISC-Bugs #46764] check MD5 and SHA1 support at startup
To: bind9-public@isc.org, fdupont@isc.org
On 01/18/2018 01:55 AM, Francis Dupont via RT wrote: > On Wed Jan 17 20:37:01 2018, pemensik@redhat.com wrote: >> Thank you Ondrej. Hello Francis, Hello Evan. >> >> Unfortunately I am not happy with this fix at all. It completely >> missed >> our intention and actually moved us even farther from solving our >> issue. > > => my interpretation of the FIPS mode according to the Guidance > document is that in FIPS mode not-approved crypto must not be > used and this applies to applications ("user" in FIPS terms) too. > > So I can see 3 different solutions, none perfect of course: > > 1- build one bind package with MD5, DSA and DH disabled > (DSA because it uses old and unsafe parameters, DH for > the same reason and because its only usage implies MD5). > It should work well in both FIPS mode enabled or disabled, > the only obvious drawback is it does not work (in fact it > impossible to configure) with TSIG HMAC-MD5. > Note command usages are updated too so attempts > to use MD5 raise understandable errors. > I don't consider old rndc versions because rndc should > come with named and do not accept old configs > using MD5 at both sides is IMHO a good thing as > soon as error messages are clear about the problem. Default algorithm used for automatically generated RNDC key were changed 3 months ago [1]. Automatic removal and regeneration of existing keys are not preferred operation. Just for this reason default build without HMAC-MD5 support at all is not desired. FIPS users are important but majority of users should be able to use MD5 based operations, if they wish. > > 2- build two packages. That means more burden on maintenance efforts. We already build two variants bind and bind-pkcs11. We would have to change dependencies that use it, especially bind-dyndb-ldap. We want to avoid this if different solution is at hand. > > 3- Disable FIPS mode when MD5 is enabled at initialization time, > or build bind with internal MD5 code. In both case they make > bind behaves as without FIPS but I am not a big fan of them > because they clearly defeat the FIPS mode idea. I think way how FIPS is enabled is not clear here. FIPS mode is enabled for whole machine. It is not enabled by application, but at boot of the system. You cannot just disable it from the application. System libraries are just different. MD5 code should not be internal, but trusted and certified library calls should be used for any MD5 operations. This way, once FIPS is active, whole application cannot do a single MD5 checksum. That is the way we archieve MD5 as disabled, while BIND still has references to MD5 in code. 4- Use either --with-openssl-hash or --enable-native-pkcs11. Build BIND in a way all crypto operations are forwarded to trusted crypto libraries. They should be as fast as any internal implementation, only some indirect calls are included. If these calls are known to fail, behave the same way like in point 1. Refuse any request to do MD5 operation in FIPS mode. Refuse to start if MD5 or DH key is used in configuration. Make different default algorithm in ddns-confgen, so no MD5 keys are generated, refuse if requested. If any MD5 operation requested, respond with unknown algorithm or just refused, failed etc. We want number 4 in RHEL. This is what my original patch solved somehow. It was invasive, sure. Because it took into account MD5 can fail. It allowed such failure to be reported and continue to run. There can be different ways to accomplish the same goal. With less changes to the basic API, if that is not desired. I had no such feedback however. > >> Once FIPS mode is enabled in target system, crypto library disables >> support for MD5. Any try to use md5 will result in error. > > => it does not make sense: either MD5 is supported or it is not. > Let's try a simple test, generate md5 checksum. On FIPS enabled machine: $ echo test | openssl md5 Error setting digest md5 140187769722784:error:060800A3:digital envelope routines:EVP_DigestInit_ex:disabled for fips:digest.c:251: On different machine with FIPS disabled: # echo test | openssl md5 (stdin)= d8e8fca2dc0f896fd7cb4cb0031ba249 MD5 calls are not removed from openssl library. They just fail in FIPS mode. Always. They will never give you any digest you can use. I would say that means MD5 is not supported. >> Only difference we would like archieve behavior similar to defined >> PK11_MD5_DISABLE in pk11/site.h. > > => the PK11_MD5_DISABLE feature comes from an old (2008) > ticket opened by Adam Tkac from Red Hat about FIPS mode > support. At that time the FIPS code was the OpenSSL FIPS > object module and it was clear that a bind using it should > not have MD5 support. It was never released but it leads > to remove first MD5 dependencies and after defaults. > When HSMs without MD5 support appeared the site.h > file was added to allows them to be used. RHEL 6 does not have pkcs11 variant build. Default version uses only internal implementation. Such build is not clearly FIPS compatible. Request for FIPS compatibility came to FreeIPA team. Because RHEL 7 has bind-pkcs11 variant and FreeIPA use it, we thought we can make it FIPS compatible. We failed to test it properly however. BIND is just one part of more complex FreeIPA Identity Management project. > For different reasons, for instance recommendations > of early OpenSSL FIPS guides, it was chosen to disable > MD5 by an option at build time. BTW it provides a strong > guarantee that MD5 code cannot be called: as it is not > in the binary it is not reachable. Of course you can object > that it is to make security before usability... > If you have an usage for it the -P flag was reserved in > all command arguments at that time for switching > to FIPS mode per application. Different build for FIPS mode will not help. Red Hat require FIPS enabled on whole machine, not per application. We do not want to support separate repository for FIPS builds. We managed to make OpenSSL work. We just want to use it, but handle errors without fatal error. > >> That means any request to use MD5 will fail like it was >> not supported at all > > => note this applies to configuration / command line > arguments, etc, not to the MD5 low level crypto. > Or with other words the PK11_MD5_DISABLE approach is > the right one and your concern is it is a built time vs. > run time. Yes. We require just runtime switch to disable MD5 by runtime library call. If commands offer HMAC-MD5 algorithm in help or manual page, that is ok. They just have to fail. We can document that in an article with details on FIPS support of BIND. > >> Because we support older version 9.9 which does not contain different >> than HMAC-MD5 rndc key support, we cannot remove whole support from >> the build. > > => argh! Partially my fault as I was late to convince my > colleagues to go far from MD5. As far as I know 9.9 is EOL in June. > We could do much better much earlier. I did not realize RNDC has alternative to disable-algorithms too late. And modification of autogeneration script to choose different algorithm by default was simple as well. I am not blaming anyone for this. I could do more as well. >> Current RT #46764 patch committed with id >> 614d838acf4e4b61523a044fde014d8ee7f60e70 would not help us. In fact, >> we >> would have to revert that in our code to support FIPS mode. > > => it is in #ifndef PK11_MD5_DISABLE code so anyway > you have to address it. IMHO you should keep it downgrading > to a sanity check: if it is reached something went really wrong > before. And it includes better error messages. > Sure, sanity check might be good. It would save us trouble if it were there before. We would notice sooner. Sanity check is good. But we do not want to prevent start in FIPS mode. >> I am sorry I was not clear enough from the start. This patch would >> prevent us starting named in FIPS mode. > > => prevent to start a named (or any command using crypto) > which wants to freely use MD5. > That is the point. I want it to only forbid or just fail use of MD5. >> We would like to use --with-openssl-hash in the future. > > => BTW another heritage of the old FIPS mode work with > in addition the fact that OpenSSL is clearly faster > (visible different with NSEC3 iterated hash). > It was recently made the default when bind is built > with OpenSSL. Sure. But if it were the default, we would not be able to start any named in FIPS mode. Now only named-pkcs11 has problems and named is not compliant. Not good, we want both fixed. That was the reason I did propose digest functions to return result code indicating success. There might be different reasons for OpenSSL to fail. It is not under our control to support all of them. > >> Our current >> problem is with --enable-native-pkcs11 variant. > > => as no HSM implements a consistent subset of PKCS#11 > I am afraid the idea of to provide a bind package with native > PKCS#11 will never work. BTW only SoftHSMv2 with OpenSSL > backend (and not in FIPS mode) can run all the system tests... > Can you try it on a system in FIPS mode? Can you make it pass somehow? :) [1] https://bugzilla.redhat.com/show_bug.cgi?id=1508003 -- Petr Menšík Software Engineer Red Hat, http://www.redhat.com/ email: pemensik@redhat.com PGP: 65C6C973
So, if I am reading this correctly. If we were to change PK11_MD5_DISABLE logic into a global flag (e.g. runtime detection) instead of configure time option that would basically satisfy your needs as it would make BIND not fail when MD5 would be used, and same binary could be used. The ABI would stay stable for maintenance releases and it would be easier to backport than the originally proposed patch. Do I understand the situation from RedHat point of view correctly? Ondrej On Thu Jan 18 12:14:29 2018, pemensik@redhat.com wrote: > > > On 01/18/2018 01:55 AM, Francis Dupont via RT wrote: > > On Wed Jan 17 20:37:01 2018, pemensik@redhat.com wrote: > >> Thank you Ondrej. Hello Francis, Hello Evan. > >> > >> Unfortunately I am not happy with this fix at all. It completely > >> missed > >> our intention and actually moved us even farther from solving our > >> issue. > > > > => my interpretation of the FIPS mode according to the Guidance > > document is that in FIPS mode not-approved crypto must not be > > used and this applies to applications ("user" in FIPS terms) too. > > > > So I can see 3 different solutions, none perfect of course: > > > > 1- build one bind package with MD5, DSA and DH disabled > > (DSA because it uses old and unsafe parameters, DH for > > the same reason and because its only usage implies MD5). > > It should work well in both FIPS mode enabled or disabled, > > the only obvious drawback is it does not work (in fact it > > impossible to configure) with TSIG HMAC-MD5. > > Note command usages are updated too so attempts > > to use MD5 raise understandable errors. > > I don't consider old rndc versions because rndc should > > come with named and do not accept old configs > > using MD5 at both sides is IMHO a good thing as > > soon as error messages are clear about the problem. > Default algorithm used for automatically generated RNDC key were changed > 3 months ago [1]. Automatic removal and regeneration of existing keys > are not preferred operation. Just for this reason default build without > HMAC-MD5 support at all is not desired. FIPS users are important but > majority of users should be able to use MD5 based operations, if they wish. > > > > 2- build two packages. > That means more burden on maintenance efforts. We already build two > variants bind and bind-pkcs11. We would have to change dependencies that > use it, especially bind-dyndb-ldap. We want to avoid this if different > solution is at hand. > > > > 3- Disable FIPS mode when MD5 is enabled at initialization time, > > or build bind with internal MD5 code. In both case they make > > bind behaves as without FIPS but I am not a big fan of them > > because they clearly defeat the FIPS mode idea. > I think way how FIPS is enabled is not clear here. FIPS mode is enabled > for whole machine. It is not enabled by application, but at boot of the > system. You cannot just disable it from the application. System > libraries are just different. MD5 code should not be internal, but > trusted and certified library calls should be used for any MD5 > operations. This way, once FIPS is active, whole application cannot do a > single MD5 checksum. That is the way we archieve MD5 as disabled, while > BIND still has references to MD5 in code. > > 4- Use either --with-openssl-hash or --enable-native-pkcs11. Build BIND > in a way all crypto operations are forwarded to trusted crypto > libraries. They should be as fast as any internal implementation, only > some indirect calls are included. If these calls are known to fail, > behave the same way like in point 1. Refuse any request to do MD5 > operation in FIPS mode. Refuse to start if MD5 or DH key is used in > configuration. Make different default algorithm in ddns-confgen, so no > MD5 keys are generated, refuse if requested. If any MD5 operation > requested, respond with unknown algorithm or just refused, failed etc. > > We want number 4 in RHEL. This is what my original patch solved somehow. > It was invasive, sure. Because it took into account MD5 can fail. It > allowed such failure to be reported and continue to run. There can be > different ways to accomplish the same goal. With less changes to the > basic API, if that is not desired. I had no such feedback however. > > > >> Once FIPS mode is enabled in target system, crypto library disables > >> support for MD5. Any try to use md5 will result in error. > > > > => it does not make sense: either MD5 is supported or it is not. > > > Let's try a simple test, generate md5 checksum. > > On FIPS enabled machine: > $ echo test | openssl md5 > Error setting digest md5 > 140187769722784:error:060800A3:digital envelope > routines:EVP_DigestInit_ex:disabled for fips:digest.c:251: > > On different machine with FIPS disabled: > # echo test | openssl md5 > (stdin)= d8e8fca2dc0f896fd7cb4cb0031ba249 > > MD5 calls are not removed from openssl library. They just fail in FIPS > mode. Always. They will never give you any digest you can use. I would > say that means MD5 is not supported. > > >> Only difference we would like archieve behavior similar to defined > >> PK11_MD5_DISABLE in pk11/site.h. > > > > => the PK11_MD5_DISABLE feature comes from an old (2008) > > ticket opened by Adam Tkac from Red Hat about FIPS mode > > support. At that time the FIPS code was the OpenSSL FIPS > > object module and it was clear that a bind using it should > > not have MD5 support. It was never released but it leads > > to remove first MD5 dependencies and after defaults. > > When HSMs without MD5 support appeared the site.h > > file was added to allows them to be used. > RHEL 6 does not have pkcs11 variant build. Default version uses only > internal implementation. Such build is not clearly FIPS compatible. > > Request for FIPS compatibility came to FreeIPA team. Because RHEL 7 has > bind-pkcs11 variant and FreeIPA use it, we thought we can make it FIPS > compatible. We failed to test it properly however. BIND is just one part > of more complex FreeIPA Identity Management project. > > > For different reasons, for instance recommendations > > of early OpenSSL FIPS guides, it was chosen to disable > > MD5 by an option at build time. BTW it provides a strong > > guarantee that MD5 code cannot be called: as it is not > > in the binary it is not reachable. Of course you can object > > that it is to make security before usability... > > If you have an usage for it the -P flag was reserved in > > all command arguments at that time for switching > > to FIPS mode per application. > Different build for FIPS mode will not help. Red Hat require FIPS > enabled on whole machine, not per application. We do not want to support > separate repository for FIPS builds. We managed to make OpenSSL work. We > just want to use it, but handle errors without fatal error. > > > >> That means any request to use MD5 will fail like it was > >> not supported at all > > > > => note this applies to configuration / command line > > arguments, etc, not to the MD5 low level crypto. > > Or with other words the PK11_MD5_DISABLE approach is > > the right one and your concern is it is a built time vs. > > run time. > Yes. We require just runtime switch to disable MD5 by runtime library > call. If commands offer HMAC-MD5 algorithm in help or manual page, that > is ok. They just have to fail. We can document that in an article with > details on FIPS support of BIND. > > > >> Because we support older version 9.9 which does not contain different > >> than HMAC-MD5 rndc key support, we cannot remove whole support from > >> the build. > > > > => argh! Partially my fault as I was late to convince my > > colleagues to go far from MD5. As far as I know 9.9 is EOL in June. > > > We could do much better much earlier. I did not realize RNDC has > alternative to disable-algorithms too late. And modification of > autogeneration script to choose different algorithm by default was > simple as well. I am not blaming anyone for this. I could do more as well. > > >> Current RT #46764 patch committed with id > >> 614d838acf4e4b61523a044fde014d8ee7f60e70 would not help us. In fact, > >> we > >> would have to revert that in our code to support FIPS mode. > > > > => it is in #ifndef PK11_MD5_DISABLE code so anyway > > you have to address it. IMHO you should keep it downgrading > > to a sanity check: if it is reached something went really wrong > > before. And it includes better error messages. > > > Sure, sanity check might be good. It would save us trouble if it were > there before. We would notice sooner. Sanity check is good. But we do > not want to prevent start in FIPS mode. > >> I am sorry I was not clear enough from the start. This patch would > >> prevent us starting named in FIPS mode. > > > > => prevent to start a named (or any command using crypto) > > which wants to freely use MD5. > > > That is the point. I want it to only forbid or just fail use of MD5. > >> We would like to use --with-openssl-hash in the future. > > > > => BTW another heritage of the old FIPS mode work with > > in addition the fact that OpenSSL is clearly faster > > (visible different with NSEC3 iterated hash). > > It was recently made the default when bind is built > > with OpenSSL. > Sure. But if it were the default, we would not be able to start any > named in FIPS mode. Now only named-pkcs11 has problems and named is not > compliant. Not good, we want both fixed. That was the reason I did > propose digest functions to return result code indicating success. There > might be different reasons for OpenSSL to fail. It is not under our > control to support all of them. > > > >> Our current > >> problem is with --enable-native-pkcs11 variant. > > > > => as no HSM implements a consistent subset of PKCS#11 > > I am afraid the idea of to provide a bind package with native > > PKCS#11 will never work. BTW only SoftHSMv2 with OpenSSL > > backend (and not in FIPS mode) can run all the system tests... > > > Can you try it on a system in FIPS mode? Can you make it pass somehow? :) > > [1] https://bugzilla.redhat.com/show_bug.cgi?id=1508003 >
To: bind9-public@isc.org, fdupont@isc.org
Date: Fri, 19 Jan 2018 17:54:32 +0100
From: "Petr Menšík" <pemensik@redhat.com>
Subject: Re: [ISC-Bugs #46764] check MD5 and SHA1 support at startup
Yes, this is exactly what we want. Behave like PK11_MD5_DISABLE is defined on FIPS enabled system. Behave like it was not defined by default. I will try to prepare patch doing just that. On 01/18/2018 03:27 PM, Ondrej Sury via RT wrote: > So, if I am reading this correctly. > > If we were to change PK11_MD5_DISABLE logic into a global flag (e.g. runtime detection) instead of configure time option that would basically satisfy your needs as it would make BIND not fail when MD5 would be used, and same binary could be used. > > The ABI would stay stable for maintenance releases and it would be easier to backport than the originally proposed patch. > > Do I understand the situation from RedHat point of view correctly? > > Ondrej > > On Thu Jan 18 12:14:29 2018, pemensik@redhat.com wrote: >> >> >> On 01/18/2018 01:55 AM, Francis Dupont via RT wrote: >>> On Wed Jan 17 20:37:01 2018, pemensik@redhat.com wrote: >>>> Thank you Ondrej. Hello Francis, Hello Evan. >>>> >>>> Unfortunately I am not happy with this fix at all. It completely >>>> missed >>>> our intention and actually moved us even farther from solving our >>>> issue. >>> >>> => my interpretation of the FIPS mode according to the Guidance >>> document is that in FIPS mode not-approved crypto must not be >>> used and this applies to applications ("user" in FIPS terms) too. >>> >>> So I can see 3 different solutions, none perfect of course: >>> >>> 1- build one bind package with MD5, DSA and DH disabled >>> (DSA because it uses old and unsafe parameters, DH for >>> the same reason and because its only usage implies MD5). >>> It should work well in both FIPS mode enabled or disabled, >>> the only obvious drawback is it does not work (in fact it >>> impossible to configure) with TSIG HMAC-MD5. >>> Note command usages are updated too so attempts >>> to use MD5 raise understandable errors. >>> I don't consider old rndc versions because rndc should >>> come with named and do not accept old configs >>> using MD5 at both sides is IMHO a good thing as >>> soon as error messages are clear about the problem. >> Default algorithm used for automatically generated RNDC key were changed >> 3 months ago [1]. Automatic removal and regeneration of existing keys >> are not preferred operation. Just for this reason default build without >> HMAC-MD5 support at all is not desired. FIPS users are important but >> majority of users should be able to use MD5 based operations, if they wish. >>> >>> 2- build two packages. >> That means more burden on maintenance efforts. We already build two >> variants bind and bind-pkcs11. We would have to change dependencies that >> use it, especially bind-dyndb-ldap. We want to avoid this if different >> solution is at hand. >>> >>> 3- Disable FIPS mode when MD5 is enabled at initialization time, >>> or build bind with internal MD5 code. In both case they make >>> bind behaves as without FIPS but I am not a big fan of them >>> because they clearly defeat the FIPS mode idea. >> I think way how FIPS is enabled is not clear here. FIPS mode is enabled >> for whole machine. It is not enabled by application, but at boot of the >> system. You cannot just disable it from the application. System >> libraries are just different. MD5 code should not be internal, but >> trusted and certified library calls should be used for any MD5 >> operations. This way, once FIPS is active, whole application cannot do a >> single MD5 checksum. That is the way we archieve MD5 as disabled, while >> BIND still has references to MD5 in code. >> >> 4- Use either --with-openssl-hash or --enable-native-pkcs11. Build BIND >> in a way all crypto operations are forwarded to trusted crypto >> libraries. They should be as fast as any internal implementation, only >> some indirect calls are included. If these calls are known to fail, >> behave the same way like in point 1. Refuse any request to do MD5 >> operation in FIPS mode. Refuse to start if MD5 or DH key is used in >> configuration. Make different default algorithm in ddns-confgen, so no >> MD5 keys are generated, refuse if requested. If any MD5 operation >> requested, respond with unknown algorithm or just refused, failed etc. >> >> We want number 4 in RHEL. This is what my original patch solved somehow. >> It was invasive, sure. Because it took into account MD5 can fail. It >> allowed such failure to be reported and continue to run. There can be >> different ways to accomplish the same goal. With less changes to the >> basic API, if that is not desired. I had no such feedback however. >>> >>>> Once FIPS mode is enabled in target system, crypto library disables >>>> support for MD5. Any try to use md5 will result in error. >>> >>> => it does not make sense: either MD5 is supported or it is not. >>> >> Let's try a simple test, generate md5 checksum. >> >> On FIPS enabled machine: >> $ echo test | openssl md5 >> Error setting digest md5 >> 140187769722784:error:060800A3:digital envelope >> routines:EVP_DigestInit_ex:disabled for fips:digest.c:251: >> >> On different machine with FIPS disabled: >> # echo test | openssl md5 >> (stdin)= d8e8fca2dc0f896fd7cb4cb0031ba249 >> >> MD5 calls are not removed from openssl library. They just fail in FIPS >> mode. Always. They will never give you any digest you can use. I would >> say that means MD5 is not supported. >> >>>> Only difference we would like archieve behavior similar to defined >>>> PK11_MD5_DISABLE in pk11/site.h. >>> >>> => the PK11_MD5_DISABLE feature comes from an old (2008) >>> ticket opened by Adam Tkac from Red Hat about FIPS mode >>> support. At that time the FIPS code was the OpenSSL FIPS >>> object module and it was clear that a bind using it should >>> not have MD5 support. It was never released but it leads >>> to remove first MD5 dependencies and after defaults. >>> When HSMs without MD5 support appeared the site.h >>> file was added to allows them to be used. >> RHEL 6 does not have pkcs11 variant build. Default version uses only >> internal implementation. Such build is not clearly FIPS compatible. >> >> Request for FIPS compatibility came to FreeIPA team. Because RHEL 7 has >> bind-pkcs11 variant and FreeIPA use it, we thought we can make it FIPS >> compatible. We failed to test it properly however. BIND is just one part >> of more complex FreeIPA Identity Management project. >> >>> For different reasons, for instance recommendations >>> of early OpenSSL FIPS guides, it was chosen to disable >>> MD5 by an option at build time. BTW it provides a strong >>> guarantee that MD5 code cannot be called: as it is not >>> in the binary it is not reachable. Of course you can object >>> that it is to make security before usability... >>> If you have an usage for it the -P flag was reserved in >>> all command arguments at that time for switching >>> to FIPS mode per application. >> Different build for FIPS mode will not help. Red Hat require FIPS >> enabled on whole machine, not per application. We do not want to support >> separate repository for FIPS builds. We managed to make OpenSSL work. We >> just want to use it, but handle errors without fatal error. >>> >>>> That means any request to use MD5 will fail like it was >>>> not supported at all >>> >>> => note this applies to configuration / command line >>> arguments, etc, not to the MD5 low level crypto. >>> Or with other words the PK11_MD5_DISABLE approach is >>> the right one and your concern is it is a built time vs. >>> run time. >> Yes. We require just runtime switch to disable MD5 by runtime library >> call. If commands offer HMAC-MD5 algorithm in help or manual page, that >> is ok. They just have to fail. We can document that in an article with >> details on FIPS support of BIND. >>> >>>> Because we support older version 9.9 which does not contain different >>>> than HMAC-MD5 rndc key support, we cannot remove whole support from >>>> the build. >>> >>> => argh! Partially my fault as I was late to convince my >>> colleagues to go far from MD5. As far as I know 9.9 is EOL in June. >>> >> We could do much better much earlier. I did not realize RNDC has >> alternative to disable-algorithms too late. And modification of >> autogeneration script to choose different algorithm by default was >> simple as well. I am not blaming anyone for this. I could do more as well. >> >>>> Current RT #46764 patch committed with id >>>> 614d838acf4e4b61523a044fde014d8ee7f60e70 would not help us. In fact, >>>> we >>>> would have to revert that in our code to support FIPS mode. >>> >>> => it is in #ifndef PK11_MD5_DISABLE code so anyway >>> you have to address it. IMHO you should keep it downgrading >>> to a sanity check: if it is reached something went really wrong >>> before. And it includes better error messages. >>> >> Sure, sanity check might be good. It would save us trouble if it were >> there before. We would notice sooner. Sanity check is good. But we do >> not want to prevent start in FIPS mode. >>>> I am sorry I was not clear enough from the start. This patch would >>>> prevent us starting named in FIPS mode. >>> >>> => prevent to start a named (or any command using crypto) >>> which wants to freely use MD5. >>> >> That is the point. I want it to only forbid or just fail use of MD5. >>>> We would like to use --with-openssl-hash in the future. >>> >>> => BTW another heritage of the old FIPS mode work with >>> in addition the fact that OpenSSL is clearly faster >>> (visible different with NSEC3 iterated hash). >>> It was recently made the default when bind is built >>> with OpenSSL. >> Sure. But if it were the default, we would not be able to start any >> named in FIPS mode. Now only named-pkcs11 has problems and named is not >> compliant. Not good, we want both fixed. That was the reason I did >> propose digest functions to return result code indicating success. There >> might be different reasons for OpenSSL to fail. It is not under our >> control to support all of them. >>> >>>> Our current >>>> problem is with --enable-native-pkcs11 variant. >>> >>> => as no HSM implements a consistent subset of PKCS#11 >>> I am afraid the idea of to provide a bind package with native >>> PKCS#11 will never work. BTW only SoftHSMv2 with OpenSSL >>> backend (and not in FIPS mode) can run all the system tests... >>> >> Can you try it on a system in FIPS mode? Can you make it pass somehow? :) >> >> [1] https://bugzilla.redhat.com/show_bug.cgi?id=1508003 >> -- Petr Menšík Software Engineer Red Hat, http://www.redhat.com/ email: pemensik@redhat.com PGP: 65C6C973
I summary here recommendations for building bind9: configure flags: - --enable-openssl-hash should be on because it makes OpenSSL crypto to be used. BTW as we fixed at least a problem in the configure detection code I recommend to check in config.status and/or report it is really enabled. - --enable-crypto-rand should be on for similar reasons. As the code allows to by pass this I recommend to remove any such possibility (the idea was to keep a way to get reproducible system tests, something more than useless in production). - --with-gssapi: I have a mixed opinion about this so if you have no customers insisting to get it (mainly for compatibility with Windows directory) IMHO it is better to avoid it. - --with-ecdsa: it should be autodetected so just check it is on in the report and/or config.status - --with-gost: it is the opposite: as it uses an engine and of course is *not* FIPS-approved it should be off. - --with-eddsa: support is only in OpenSSL 1.1 so it is unlikely you get it. lib/isc/include/pk11/site.h - I'll come back about PK11_MD5_DISABLE - PK11_DSA_DISABLE should be on because DSA as it is specified in old RFCs and implemented is not secure today. Note ECDSA is the fine replacement so I can't see a reason to keep it at the exception to be compliant with a clearly obsolete RFC... - PK11_DH_DISABLE could be the same story (in worse because there are some predefined groups). It is used only for TKEY and required MD5. So at the end it will be disable statically or dynamically in FIPS mode... - PK11_PAD_HMAC_KEYS must be off as it fools the check on short keys for HMAC. - PK11_*_REPLACE and PK11_*_SKIP are really for PKCS#11 so not relevant for builds with OpenSSL. code using crypto: - OpenSSL code should use EVP. There are alternatives for old versions of OpenSSL. If you like you can get rid of them, put a #error at the first use of !USE_EVP, etc. - OpenSSL code should not use engines (this is a requirement proper to the Security Policy for Red Hat OpenSSL, i.e. the OpenSSL FIPS module allows engines to offload crypto to a HSM). There is a USE_ENGINE ifdef which disables engine code, you should try it so ENGINE_set_default() is never called. - not OpenSSL crypto code: there are a few places where not-predictable values are needed outside a crypto mechanisms so some pseudo-random generator code. We recently cleaned up and updated this code but as it is not involve into crypto operations it should not be a problem. I don't know to which version of bind last improvements were back ported... PK11_MD5_DISABLE: I think we agree what you need is the same than PK11_MD5_DISABLE but at runtime, i.e. roughly to replace #ifdef PK11_MD5_DISABLE by an "if" in the code. Even as far as I know there is no way to do it without manually editing the code the PK11_MD5_DISABLE ifdefs should cover all the places you have to add an "if" including a hidden dependency (I believe there is no other dependency but the code without MD5 was not heavily used/tested so it is possible there is still a bug somewhere...). Note that at the opposite it is very easy to check there is no hidden calls to MD5 so on the security side you can provide a high insurance.
And BTW I tried native PKCS#11 code with an OpenSSL backend in FIPS mode. It failed to run all the system tests with (too) small parameters as expected, and not expected it failed to verify the .org signature because I falled at the exact time a 1023 (1024 - 1) RSA modulus was used for .org... My conclusion was the experiment was funny but clearly it was not the best idea to do production with a crypto in FIPS mode. BTW it was some years ago and I am sure that at this time Fedora had no FIPS capable OpenSSL (i.e I had to build an OpenSSL FIPS module from sources, etc. Something which required a lot of free time). Another point: Do you need something about PKCS#11 native mode?
To: bind9-public@isc.org, fdupont@isc.org
Subject: Re: [ISC-Bugs #46764] check MD5 and SHA1 support at startup
From: "Petr Menšík" <pemensik@redhat.com>
Date: Thu, 25 Jan 2018 22:30:07 +0100
Hello Francis, Stay tuned for the patch. Unfinished and untested preview at https://github.com/pemensik/bind9/tree/feature/runtime-md5-disable On 01/20/2018 05:45 PM, Francis Dupont via RT wrote: > I summary here recommendations for building bind9: > > configure flags: > > - --enable-openssl-hash should be on because > it makes OpenSSL crypto to be used. BTW as we fixed > at least a problem in the configure detection code I recommend > to check in config.status and/or report it is really enabled. Sure, this is definitely going to be enabled. We are fixing problem in pkcs11 variant at this time, but this will be changed as soon as it is safe to run in FIPS mode. That is in Fedora, not sure when it will be done in RHEL. > > - --enable-crypto-rand should be on for similar > reasons. As the code allows to by pass this I recommend to > remove any such possibility (the idea was to keep a way > to get reproducible system tests, something more than useless > in production). Thank you for this suggestion, I think we want this as well. > > - --with-gssapi: I have a mixed opinion about this so if > you have no customers insisting to get it (mainly for > compatibility with Windows directory) IMHO it is better > to avoid it. We cannot avoid this choice, this is absolutely required. pkcs11 variant in RHEL/Fedora is there only for freeipa usage. Freeipa provides integrated solution to identity and authorization management. Kerberos integration is primary feature. No way to turn this off. > > - --with-ecdsa: it should be autodetected so just check > it is on in the report and/or config.status No support for this in 9.11.2, I think we want it. > > - --with-gost: it is the opposite: as it uses an engine and > of course is *not* FIPS-approved it should be off. This is forbidden in whole Fedora, already is off. > > - --with-eddsa: support is only in OpenSSL 1.1 so it is > unlikely you get it. This is actually true, Fedora 26 already supports OpenSSL 1.1. This would be enabled if available. It is supported only in 9.12 however, Fedora still has 9.11.2 version where this option is available. This is not relevant to RHEL 7, but I think we want it in Fedora. I will check backport possibility. > > lib/isc/include/pk11/site.h > > - I'll come back about PK11_MD5_DISABLE > > - PK11_DSA_DISABLE should be on because DSA as it > is specified in old RFCs and implemented is not secure today. > Note ECDSA is the fine replacement so I can't see a reason > to keep it at the exception to be compliant with a clearly > obsolete RFC... > > - PK11_DH_DISABLE could be the same story (in worse > because there are some predefined groups). It is used > only for TKEY and required MD5. So at the end it will > be disable statically or dynamically in FIPS mode... I am aware this is directly linked to md5. I think is there any reason it does not support any other digest algorithm? Is it only lack of demand for it? > > - PK11_PAD_HMAC_KEYS must be off as it fools the > check on short keys for HMAC. Last time I checked this in softhsm with openssl 1.1, padding with zeros did not change results of tests. Is there anything I am missing there. > > - PK11_*_REPLACE and PK11_*_SKIP are really for PKCS#11 > so not relevant for builds with OpenSSL. Not relevant for us now. Might be useful to reconfigure openssl with different engines instead of replacing like this. > > code using crypto: > > - OpenSSL code should use EVP. There are alternatives for > old versions of OpenSSL. If you like you can get rid of them, > put a #error at the first use of !USE_EVP, etc. Sure. I think most digest should be in single file, for example openssl_digest. AFAIK most openssl digest code is the same, different only in EVP_xy function passed to EVP_DigestInit. I think single static function should be used for all OpenSSL functions isc_*_init, isc_*_update, isc_*_final. Just pass EVP_xy() to it for specic function. Code would be much more simple. Similar with PKCS11 native code. I think lib/isc/md5.c, sha1.c and sha2.c should contain only built-in functions and not be linked at all when --enable-openssl-hash is used. > > - OpenSSL code should not use engines (this is a requirement > proper to the Security Policy for Red Hat OpenSSL, i.e. the > OpenSSL FIPS module allows engines to offload crypto > to a HSM). There is a USE_ENGINE ifdef which disables > engine code, you should try it so ENGINE_set_default() is > never called. Interesting. I were planning to use pkcs11 engine in future instead of native pkcs11 code. I think I will have to talk more with our crypto people to have clear requirements. > > - not OpenSSL crypto code: there are a few places where > not-predictable values are needed outside a crypto > mechanisms so some pseudo-random generator code. > We recently cleaned up and updated this code but as > it is not involve into crypto operations it should not be > a problem. I don't know to which version of bind last > improvements were back ported... > > PK11_MD5_DISABLE: > > I think we agree what you need is the same than PK11_MD5_DISABLE > but at runtime, i.e. roughly to replace #ifdef PK11_MD5_DISABLE by > an "if" in the code. Sure, so far I am adding if (isc_md5_available()) into the ifdef. That way, you can still completely disable it at compile time. If you do not, it can be disabled runtime. > > Even as far as I know there is no way to do it without > manually editing the code the PK11_MD5_DISABLE ifdefs should > cover all the places you have to add an "if" including a hidden > dependency (I believe there is no other dependency but the code > without MD5 was not heavily used/tested so it is possible > there is still a bug somewhere...). > > Note that at the opposite it is very easy to check there is no > hidden calls to MD5 so on the security side you can provide > a high insurance. > -- Petr Menšík Software Engineer Red Hat, http://www.redhat.com/ email: pemensik@redhat.com PGP: 65C6C973
On Thu Jan 25 21:30:17 2018, pemensik@redhat.com wrote: > Hello Francis, => I'll reply tomorrow (hum, far later today as it is near 01am here).
On Thu Jan 25 21:30:17 2018, pemensik@redhat.com wrote: > Unfinished and untested preview at > https://github.com/pemensik/bind9/tree/feature/runtime-md5-disable => still did not get the time to look at this... > On 01/20/2018 05:45 PM, Francis Dupont via RT wrote: > > I summary here recommendations for building bind9: > > > > configure flags: > > > > - --with-ecdsa: it should be autodetected so just check > > it is on in the report and/or config.status > No support for this in 9.11.2, I think we want it. => ECDSA is supported in 9.10 and newer so I don't understand your comment. > > - --with-eddsa: support is only in OpenSSL 1.1 so it is > > unlikely you get it. > This is actually true, Fedora 26 already supports OpenSSL 1.1. This > would be enabled if available. It is supported only in 9.12 however, > Fedora still has 9.11.2 version where this option is available. This is > not relevant to RHEL 7, but I think we want it in Fedora. I will check > backport possibility. => I believed there was no FIPS certified code based on OpenSSL 1.1... Anyway EdDSA is not FIPS approved so even it is better than ECDSA it is hard to recommend it in production today... > > lib/isc/include/pk11/site.h > > > > - PK11_DH_DISABLE could be the same story (in worse > > because there are some predefined groups). It is used > > only for TKEY and required MD5. So at the end it will > > be disable statically or dynamically in FIPS mode... > I am aware this is directly linked to md5. I think is there any reason > it does not support any other digest algorithm? Is it only lack of > demand for it? => mostly lack of demand. I tried to update it to ECDH at IETF but failed for various reasons. > > - PK11_PAD_HMAC_KEYS must be off as it fools the > > check on short keys for HMAC. > Last time I checked this in softhsm with openssl 1.1, padding with zeros > did not change results of tests. Is there anything I am missing there. => the purpose of this flag is to fool HMAC implementations which put a lower threshold on key lengths so some tests (including the second part of the new sanity check) pass. it should not be set for a code used in production. And of course padding a short key with zeros does not change the result but my point is it does not increase the entropy too. Note that as far as I know HMAC in FIPS mode should reject short keys. If you have this problem again the solution is not to leave HMAC lower functions to fail, nor of course to by pass the check but to refuse too short keys at configuration / command line decoding time. A last point: TSIG rfc2845bis has now a SHOULD about minimal key length (added by me with the support of co-authors/contributors). > > code using crypto: > > > > - OpenSSL code should not use engines (this is a requirement > > proper to the Security Policy for Red Hat OpenSSL, i.e. the > > OpenSSL FIPS module allows engines to offload crypto > > to a HSM). There is a USE_ENGINE ifdef which disables > > engine code, you should try it so ENGINE_set_default() is > > never called. > Interesting. I were planning to use pkcs11 engine in future instead of > native pkcs11 code. I think I will have to talk more with our crypto > people to have clear requirements. => in the past we had a PKCS#11 OpenSSL engine and it was a nightmare to support. This was the reason I wrote the native PKCS#11 support and it was so successful it was decided to promote and integrate it into bind9. Note that to come back to the Security Policy it explicitly prohibits calls to the ENGINE_set_default() function so IMHO the use of a HSM (make sense because if you have a HSM you don't need OpenSSL and the "one crypto only" rule applies). Again if you have questions about the PKCS#11 native support I am ready to answer.
To: bind9-public@isc.org, fdupont@isc.org
Date: Fri, 9 Mar 2018 14:47:33 +0100
Subject: Re: [ISC-Bugs #46764] check MD5 and SHA1 support at startup
From: "Petr Menšík" <pemensik@redhat.com>
Hi Francis, finally I finished somehow working version. I moved it to ISC gitlab branch : I made changes to tests to make it pass with MD5 algorithm disabled and enabled from the same source. This is not final version, because I found some problems. First is stronger requirement on minimal DSA keys that I had to change. Second is change from all default hmac-md5 keys make problem, I had to specify algorithm in -y parameters of dig and nsupdate. Also in nsupdate key statement. I will create issues for them on gitlab. Could you please look at it if such approach is possible? On 01/27/2018 12:34 AM, Francis Dupont via RT wrote: > On Thu Jan 25 21:30:17 2018, pemensik@redhat.com wrote: >> Unfinished and untested preview at >> https://github.com/pemensik/bind9/tree/feature/runtime-md5-disable > > => still did not get the time to look at this... > >> On 01/20/2018 05:45 PM, Francis Dupont via RT wrote: >>> I summary here recommendations for building bind9: >>> >>> configure flags: >>> >>> - --with-ecdsa: it should be autodetected so just check >>> it is on in the report and/or config.status >> No support for this in 9.11.2, I think we want it. > > => ECDSA is supported in 9.10 and newer so I don't understand > your comment. I am sorry I was just tired and swapped ECDSA and EdDSA support in versions. Please ignore that. > >>> - --with-eddsa: support is only in OpenSSL 1.1 so it is >>> unlikely you get it. >> This is actually true, Fedora 26 already supports OpenSSL 1.1. This >> would be enabled if available. It is supported only in 9.12 however, >> Fedora still has 9.11.2 version where this option is available. This is >> not relevant to RHEL 7, but I think we want it in Fedora. I will check >> backport possibility. > > => I believed there was no FIPS certified code based on OpenSSL 1.1... > Anyway EdDSA is not FIPS approved so even it is better than ECDSA > it is hard to recommend it in production today... According to FIPS presentation on Devconf [2] EdDSA might be allowed in future. Of course for now it is not FIPS ceritified. Its support is not yet in any supported RHEL version AFAIK. I think there might be something soon. We can enable it as experimental feature on Fedora and disable it on RHEL build, until it is certified. I have to backport runtime MD5 disable to version 9.9 used in RHEL 7, because already released version has issue with it. That version is still linked against OpenSSL 1.0. > >>> lib/isc/include/pk11/site.h >>> >>> - PK11_DH_DISABLE could be the same story (in worse >>> because there are some predefined groups). It is used >>> only for TKEY and required MD5. So at the end it will >>> be disable statically or dynamically in FIPS mode... >> I am aware this is directly linked to md5. I think is there any reason >> it does not support any other digest algorithm? Is it only lack of >> demand for it? > > => mostly lack of demand. I tried to update it to ECDH at IETF > but failed for various reasons. > >>> - PK11_PAD_HMAC_KEYS must be off as it fools the >>> check on short keys for HMAC. >> Last time I checked this in softhsm with openssl 1.1, padding with zeros >> did not change results of tests. Is there anything I am missing there. > > => the purpose of this flag is to fool HMAC implementations > which put a lower threshold on key lengths so some tests > (including the second part of the new sanity check) pass. > it should not be set for a code used in production. > And of course padding a short key with zeros does not change > the result but my point is it does not increase the entropy too. > Note that as far as I know HMAC in FIPS mode should reject > short keys. If you have this problem again the solution is not > to leave HMAC lower functions to fail, nor of course to by pass > the check but to refuse too short keys at configuration / > command line decoding time. > A last point: TSIG rfc2845bis has now a SHOULD about > minimal key length (added by me with the support of > co-authors/contributors). This is one of issues I have met. I think it should be more simple to change limits of useable keys. Especially in tests, where it uses short keys only to save CPU on testing (I think). > >>> code using crypto: >>> >>> - OpenSSL code should not use engines (this is a requirement >>> proper to the Security Policy for Red Hat OpenSSL, i.e. the >>> OpenSSL FIPS module allows engines to offload crypto >>> to a HSM). There is a USE_ENGINE ifdef which disables >>> engine code, you should try it so ENGINE_set_default() is >>> never called. >> Interesting. I were planning to use pkcs11 engine in future instead of >> native pkcs11 code. I think I will have to talk more with our crypto >> people to have clear requirements. > > => in the past we had a PKCS#11 OpenSSL engine and it was > a nightmare to support. This was the reason I wrote the native > PKCS#11 support and it was so successful it was decided > to promote and integrate it into bind9. > > Note that to come back to the Security Policy it explicitly prohibits > calls to the ENGINE_set_default() function so IMHO the use of > a HSM (make sense because if you have a HSM you don't need > OpenSSL and the "one crypto only" rule applies). > > Again if you have questions about the PKCS#11 native support > I am ready to answer. > [1] https://gitlab.isc.org/pemensik/bind9/tree/feature/master/runtime-md5-disable [2] https://devconfcz2018.sched.com/event/DJYH/fips-140-2-compliance-for-developers -- Petr Menšík Software Engineer Red Hat, http://www.redhat.com/ email: pemensik@redhat.com PGP: 65C6C973