[fips] ntpq segfaults when attempting to use MD5 from FIPS-openssl library.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
ntp (Ubuntu) |
Invalid
|
Undecided
|
Unassigned | ||
Bionic |
Fix Released
|
Undecided
|
Unassigned | ||
openssl (Ubuntu) |
Fix Released
|
Medium
|
Joy Latten | ||
Bionic |
Invalid
|
Medium
|
Unassigned |
Bug Description
[Impact]
In FIPS mode on Bionic MD5 is semi-disabled causing some applications to segfault.
ntpq uses crypto hashes to authenticate its requests. By default it uses md5. However, when compiled with openssl it creates a lists of acceptable hashes from openssl that can be used.
This issue is only applicable in bionic and when using fips-openssl.
[Test Steps]
Test case:
sudo apt install ntp
ntpq -p
Segmentation fault (core dumped)
What happens there is ntpq wants to iterate all available digests (list_digest_names in ntpq.c). It uses EVP_MD_
EVP_MD_
For FIPS mode it adds:
EVP_add_
What happens later in ntpq is (list_md_fn function inside ntpq.c):
ctx = EVP_MD_CTX_new();
EVP_DigestInit(ctx, EVP_get_
EVP_DigestFinal
First digest it gets is MD5, but while running EVP_DigestInit for it, it gets to this point (openssl/
#ifdef OPENSSL_FIPS
if (FIPS_mode()) {
if (!(type->flags & EVP_MD_FLAG_FIPS)
&& !(ctx->flags & EVP_MD_
}
}
#endif
Due to type->flags for MD5 being 0 there's an error set (EVP_R_
After getting back to ntpq.c:
ctx->engine and ctx->digest are not set (due to the mentioned error), hence
inside EVP_DigestFinal_ex (openssl/
OPENSSL_
causes a segfault (ctx->digest is NULL).
So either MD5 shouldn't be added in FIPS mode or it should have the EVP_MD_FLAG_FIPS to be properly initialized.
[Regression Potential]
I don't think this should regress ntpq + openssl from the Ubuntu archive.
Current archive ntpq + openssl behaviour:
openssl includes all message digests and hands ntpq a sorted digest-list.
ntpq doesn't check return from EVP_Digest(
i.e.
ntpq> help keytype
function: set key type to use for authenticated requests, one of:
MD4, MD5, RIPEMD160, SHA1, SHAKE128
If somehow openssl library is corrupted and sends back erroneous results, its possible the authentication will just not ever work.
Newly fixed archive ntpq + oenssl beahviour:
openssl includes all message digests and hands ntpq a sorted digest-list.
ntpq checks each one and includes each working digest. With a non-corrupted openssl, everything works fine and ntpq includes each into its list. Ends up with a list identical to the one above.
If somehow opensll library is corrupted and sends back erroneous results, ntpq will hopefully catch it by checking return code and include only those algos that appear to be working. Its possible authentication will work for ntpq.
The difference will be seen in ntpq + fips-openssl. ntpq will check return, and for fips-not-approved algos, return will indicate an error. So these algos will be skipped and ntpq will not include into its digest list. Resulting in a much shorter list of only fips-approved algos.
i.e.
ntpq> help keytype
function: set key type to use for authenticated requests, one of:
SHA1, SHAKE128
Since md5 is ntpq's default auth algo, this will need to be changed to one of the above algos in the config files.
But I think it is somewhat understood that MD5 is bad in a FIPS environment.
Changed in openssl (Ubuntu Bionic): | |
importance: | Undecided → Medium |
information type: | Public → Public Security |
description: | updated |
description: | updated |
description: | updated |
Changed in openssl (Ubuntu): | |
assignee: | nobody → Joy Latten (j-latten) |
Changed in openssl (Ubuntu Bionic): | |
status: | New → Confirmed |
Changed in openssl (Ubuntu): | |
status: | New → In Progress |
summary: |
- [fips] Not fully initialized digest segfaulting some client applications + [fips] ntpq segfaults when attempting to use MD5 from FIPS-openssl + library. |
description: | updated |
description: | updated |
tags: |
added: verification-done verification-done-bionic removed: verification-needed verification-needed-bionic |
FTR: EVP_add_ digest( EVP_md5( )); is not present in the Xenial build, hence there's no crash there.