[MDEV-32368] Docker image crashes on launch with OpenSSL 3 FIPS activated Created: 2023-10-06 Updated: 2023-11-26 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Docker |
| Affects Version/s: | 10.11.5, 11.1.2 |
| Fix Version/s: | 10.11 |
| Type: | Bug | Priority: | Major |
| Reporter: | Cory McCarty | Assignee: | Vladislav Vaintroub |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Official Docker image |
||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Description |
|
I've built a docker image based on the official MariaDB image, but with the OpenSSL FIPS provider (v3.0.0) built and configured for use (but no other changes). When I try to run this image, it crashes on launch after logging [Entrypoint]: Initializing database files. I've tried with both mariadb:11-jammy and mariadb:10-jammy with the same results. I've also tried doing a full build of OpenSSL 3.0.8 with its FIPS provider and configuring the system to use that OpenSSL, also with the same results. I assume based on the documentation here that MariaDB is intended to function correctly with OpenSSL 3 using the FIPS provider. I have confirmed using the ldd command on that page that the server is dynamically linking against the expected OpenSSL libraries. I've attached the output (both stdout and stderr) from running docker logs on the container (crashlog.txt) as well as the Dockerfile and openssl.cnf files used to build the container. For convenience, here are the full instructions to reproduce. First, put the attached Dockerfile and opensl.cnf in a directory. From that directory, build the image:
Then run the image:
After a couple of seconds, observe that the container has stopped and check the logs:
|
| Comments |
| Comment by Daniel Black [ 2023-10-06 ] | ||||||||||||||||||||||||||||||
|
Seems related https://github.com/MariaDB/server/commit/f23f45413fd02c180182cd341b800e2b9fa169f4 | ||||||||||||||||||||||||||||||
| Comment by Cory McCarty [ 2023-10-06 ] | ||||||||||||||||||||||||||||||
|
That seems like it makes sense. If I'm understanding the comments in that code correctly (admittedly a big "if"), it sounds like it's trying to go ahead and use MD5 despite FIPS mode since it's not using it for a crypto operation. But I don't think OpenSSL can provide MD5 in FIPS mode since it's not included in the "base" (non-crypto) or FIPS providers. (To be fair, there's a fair amount I don't understand here, including the entirety of the internals of MariaDB, so I could be way off base.) | ||||||||||||||||||||||||||||||
| Comment by Daniel Black [ 2023-10-06 ] | ||||||||||||||||||||||||||||||
|
serg, know what's going on here? | ||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2023-10-07 ] | ||||||||||||||||||||||||||||||
|
Not really. cory.mccarty is right that that code is using MD5 despite FIPS mode since it's not using it for a crypto operation. It works, because it explicitly tells OpenSSL that it's ok to do it despite FIPS. We have tests, on a dedicated openssl3+fips builder to verify that MariaDB works in such a setup. | ||||||||||||||||||||||||||||||
| Comment by Cory McCarty [ 2023-10-09 ] | ||||||||||||||||||||||||||||||
|
Have you confirmed that the test builder has OpenSSL fully configured for FIPS mode? As before, there are significant limitations to my understanding of how this works, so I apologize if this I've got something wrong or this isn't helpful, but I don't think it should be possible to use MD5 from OpenSSL's high-level APIs if it's in FIPS mode because it won't actually have a provider that includes that algorithm. (I gather there are ways to bypass the FIPS configuration using lower-level APIs, so maybe that's what you're doing?) The best mechanism I've found to check whether OpenSSL is fully in FIPS mode is to run openssl list -digest-algorithms and make sure all the algorithms listed under "Provided" end with "@ fips", indicating that they're from the FIPS provider. (You can use any of the other algorithm types as well, not just digest.) | ||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2023-10-09 ] | ||||||||||||||||||||||||||||||
|
apparently, according to the patch, it indeed explicitly asks for a non-fips algorithm:
And according to https://www.openssl.org/docs/manmaster/man7/ossl-guide-libraries-introduction.html
Does this "may" means that FIPS provider also "may" not contain them? How it can be done? | ||||||||||||||||||||||||||||||
| Comment by Daniel Black [ 2023-10-10 ] | ||||||||||||||||||||||||||||||
|
possible, stack trace looks a null pointer call. https://github.com/openssl/openssl/blob/master/providers/fips/fipsprov.c#L276 - on digest there's no FIPS_UNAPPROVED_PROPERTIES | ||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2023-10-10 ] | ||||||||||||||||||||||||||||||
|
Oh, so, indeed, may be the builder doesn't properly enable fips? Perhaps using "provider=default" will work better then "fips=no". Or using a non-fips context. And ff nothing else works we can bundle MD5 implementation with the server. | ||||||||||||||||||||||||||||||
| Comment by Vladislav Vaintroub [ 2023-10-11 ] | ||||||||||||||||||||||||||||||
|
Is this supposed to work as described at all? Dockerfile builds own copy of openssl with fips, then ovewrites system libraries with own openssl. Not sure it can work like that. That assumes libraries are ABI compatible, but I do not believe there is a guarantee. The way to handle it, as I see it, is to build openssl with fips first, then build server against openssl-with-fips libraries and headers. Which is what I did, and it worked fine. Maybe I'm missing something? Below is what I did, on ubuntu-22.04
Now I test it like this
Now I check that mariadbd really links against my own openssl, and yes, it does link against /usr/local/lib64/ SSL libraries
| ||||||||||||||||||||||||||||||
| Comment by Cory McCarty [ 2023-10-11 ] | ||||||||||||||||||||||||||||||
|
You can also just build the OpenSSL FIPS module and configure the system version of OpenSSL that's included in the original MariaDB image to be in FIPS mode (which is a configuration that is recognized/recommended by OpenSSL), and the result is the same. In that case, MariaDB is still linking against the system OpenSSL, and the image still crashes on launch. (Also, note that just running ./Configure enable-fips doesn't actually update the OpenSSL configuration file to turn on FIPS mode. | ||||||||||||||||||||||||||||||
| Comment by Cory McCarty [ 2023-10-25 ] | ||||||||||||||||||||||||||||||
|
To expand on my previous comment, I've attached a different Dockerfile and openssl.cnf (maybe not linked correctly from this comment since they have the same names as the original attachments) that use the system OpenSSL and just build and install the FIPS module (and configure OpenSSL to use it, since just installing it doesn't mean it gets used). It's somewhat of an odd configuration because it's using a slightly older version of the FIPS module than the version of OpenSSL because only certain versions of the FIPS module are actually FIPS validated (3.0.0 and 3.0.8; this configuration uses 3.0.0). The OpenSSL documentation suggests that this is a valid configuration. I strongly suspect that you would get the same results from just building the version of the FIPS module that matches the OpenSSL version, but that version wouldn't actually be FIPS validated. |