Bug 1220681

Summary: [Build 59.2] apache refuses to start with FIPS environment variables
Product: [openSUSE] PUBLIC SUSE Linux Enterprise Server 15 SP6 Reporter: Timo Jyrinki <tjyrinki>
Component: Security CertificationsAssignee: David Anes <david.anes>
Status: REOPENED --- QA Contact:
Severity: Major    
Priority: P2 - High CC: certification-bugs, david.anes, felice.maccaro, jan.stehlik, jcheung, meissner, otto.hollmann, pmonrealgonzalez, rtsvetkov, swayammitra.tripathy
Version: unspecifiedFlags: rtsvetkov: needinfo? (jan.stehlik)
Target Milestone: ---   
Hardware: Other   
OS: Other   
URL: https://openqa.suse.de/tests/13641573/modules/apache_ssl/steps/34
Whiteboard: FIPS
Found By: openQA Services Priority:
Business Priority: Blocker: No
Marketing QA Status: --- IT Deployment: ---
Bug Depends on:    
Bug Blocks: 1220333    
Attachments: httpd-prefork core dump
journal and apache logs

Description Timo Jyrinki 2024-02-29 13:32:14 UTC
On Build 59.2 apache fails to start under FIPS mode with:

AH00526: Syntax error on line 159 of /etc/apache2/ssl-global.conf:
start_apache2[7283]: SSLFIPS invalid, rebuild httpd and openssl compiled for FIPS

There doesn't seem to anything other useful in system logs (https://openqa.suse.de/tests/13641573#downloads), but packages installed by FIPS pattern are:

(1/5) Installing: libkcapi-tools-0.13.0-150600.15.3.aarch64 [..done]
(2/5) Installing: libopenssl-3-fips-provider-3.1.4-150600.1.11.aarch64 [..done]
(3/5) Installing: openssh-fips-9.3p2-150600.1.1.aarch64 [..done]
(4/5) Installing: dracut-fips-059+suse.506.gd33b6bef-150600.1.32.aarch64 [..done]
(5/5) Installing: patterns-base-fips-20200124-150600.28.1.aarch64 [..done]
Comment 1 Marcus Meissner 2024-02-29 13:42:33 UTC
Apache2 is now built against openssl3, so it might need adjustments for FIPS.
Comment 5 Radoslav Tzvetkov 2024-03-18 10:32:15 UTC
So, this seems resolved?
Comment 6 Radoslav Tzvetkov 2024-03-18 10:32:51 UTC
merged
Comment 8 Timo Jyrinki 2024-03-26 07:51:02 UTC
Created attachment 873804 [details]
httpd-prefork core dump

With Build71.1 now getting core dump instead on a similar FIPS setup when starting apache:

Mar 22 14:55:26 susetest systemd[1]: apache2.service: Main process exited, code=dumped, status=11/SEGV
Mar 22 14:55:26 susetest systemd[1]: apache2.service: Failed with result 'core-dump'.
Comment 10 Timo Jyrinki 2024-03-26 07:51:55 UTC
Reopening for still not starting, see attachments.
Comment 11 Pedro Monreal Gonzalez 2024-03-26 09:35:10 UTC
Could somebody get a back trace with debuginfo files installed? TIA
Comment 12 Pedro Monreal Gonzalez 2024-03-26 10:17:21 UTC
There are various upstram fixes that could be related (1913912, 1914365, 1916054, 1915067). See also:

https://github.com/apache/httpd/pull/402
https://src.fedoraproject.org/rpms/httpd/blob/rawhide/f/httpd-2.4.58-r1913912+.patch
https://src.fedoraproject.org/rpms/httpd/blob/rawhide/f/httpd-2.4.58-r1914365.patch

Once we get a full bt or access to an SP6 vm in FIPS mode we could circle the problem.
Comment 13 Timo Jyrinki 2024-03-26 11:18:19 UTC
Access to VM provided.
Comment 14 Pedro Monreal Gonzalez 2024-03-26 18:06:12 UTC
I could not extract more info from the core file. The debuginfo files have been installed now but I haven't been able to reproduce the issue. Maybe if somebody can reproduce now. The command that segfaulted before was something like:

> httpd-prefork -DSYSCONFIG -DSSL -C 'PidFile /run/httpd.pid' -C 'Include /etc/apache2/sysconfig.d/include.conf' -C 'Include /etc/apache2/sysconfig.d/include.conf' -DSYSTEMD -DFORGROUND -k start

The service fails to start but does not dump a core, the error message now is:

> AH00557: httpd: apr_sockaddr_info_get() failed for dev-server
> AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
Comment 15 Timo Jyrinki 2024-03-27 10:30:54 UTC
I've narrowed down the core dump problem to when using environment variable FIPS mode (not kernel boot parameter fips=1). That is, in /etc/bash.bashrc:

export OPENSSL_FIPS=1
export OPENSSL_FORCE_FIPS_MODE=1

Additionally, "SSLFIPS on" in /etc/apache2/ssl-global.conf.

Re-tested manually on the new 73.1 build.

The lack of good/compatible debuginfo packages remains a problem. I've now a compressed pre-setupped VM image available for debugging.
Comment 16 David Anes 2024-03-27 10:37:22 UTC
I'm preparing an updated version with some patches (difficult to know without debuginfo).

@Timo: Let me finish them and I'll let you know. Would you be able to test these new packages once they build?
Comment 17 Timo Jyrinki 2024-03-27 11:36:32 UTC
Sure, today or tomorrow.
Comment 18 Timo Jyrinki 2024-03-28 07:58:46 UTC
Created attachment 873879 [details]
journal and apache logs

I got updated packages from David this morning and tested them. Findings:

- Core dump problem is fixed now!
- However, apache still refuses to start, due to "SSL Library Error: error:0A0000A1:SSL routines::library has no ciphers".
- I also reasserted on this VM if I put fips=1 to kernel parameters, apache starts. Removing it, relying on the environment variables, brings back the problem.

So this is now a third time a bug is being fixed and yet another problem uncovered, I will the change the title of this poor bug report to reflect that.
Comment 19 David Anes 2024-03-28 08:13:16 UTC
(In reply to Timo Jyrinki from comment #18)
> Created attachment 873879 [details]
> journal and apache logs
> 
> I got updated packages from David this morning and tested them. Findings:
> 
> - Core dump problem is fixed now!

Phew!

> - However, apache still refuses to start, due to "SSL Library Error:
> error:0A0000A1:SSL routines::library has no ciphers".

I requested some help from crypto/openssl people. Let's see.

> - I also reasserted on this VM if I put fips=1 to kernel parameters, apache
> starts. Removing it, relying on the environment variables, brings back the
> problem.

At least we have a workaround.

> 
> So this is now a third time a bug is being fixed and yet another problem
> uncovered, I will the change the title of this poor bug report to reflect
> that.

Yes, please ;)

For now, I just sent the updates to GA here:
- https://build.suse.de/request/show/325026
Comment 20 Radoslav Tzvetkov 2024-03-28 15:37:58 UTC
Staged on S. Should come next week
Comment 21 Radoslav Tzvetkov 2024-04-02 08:40:31 UTC
A submit request mentioning this bug  was successfully integrated into build 77.1.

Please set it as resolved and eventually verify.
Comment 22 Radoslav Tzvetkov 2024-04-02 10:09:47 UTC
Please indicate the current expectation for fixing the bug using the Target Milestone field. What do we believe is possible? 

In the cases where we do not plan to deliver or cannot guess (!?) please do not enter anything, but you can comment if you wish to provide more details.
Comment 23 Timo Jyrinki 2024-04-03 05:31:48 UTC
Apache2 is still failing to start on 77.1 (with FIPS env vars).

(In reply to David Anes from comment #19)
> I requested some help from crypto/openssl people. Let's see.

Yes, I provided Otto a VM where this can be reproduced last week. I can respin it based on 77.1 if needed.

> > - I also reasserted on this VM if I put fips=1 to kernel parameters, apache
> > starts. Removing it, relying on the environment variables, brings back the
> > problem.
> At least we have a workaround.

That is not a real workaround in the sense that we have two ways of supporting FIPS, the kernel mode and using the environment variables, and both are expected to work. But yes, it's anyway very useful to narrow down where things might go wrong.
Comment 24 David Anes 2024-04-03 07:14:18 UTC
@Otto/@Pedro do you think "SSL Library Error: error:0A0000A1:SSL routines::library has no ciphers" is a configuration error on the side of Apache or on the side of OpenSSL/system?

It's interesting that it works enabling fips at kernel level but not via envvars.(In reply to Timo Jyrinki from comment #23)

> That is not a real workaround in the sense that we have two ways of
> supporting FIPS, the kernel mode and using the environment variables, and
> both are expected to work. But yes, it's anyway very useful to narrow down
> where things might go wrong.

I agree, at least we know that apache works in fips mode, therefore it seems something config-related or a silly issue somewhere.
Comment 25 Pedro Monreal Gonzalez 2024-04-03 08:23:42 UTC
Hi, David. See my comment inline.

(In reply to David Anes from comment #24)
> @Otto/@Pedro do you think "SSL Library Error: error:0A0000A1:SSL
> routines::library has no ciphers" is a configuration error on the side of
> Apache or on the side of OpenSSL/system?

Most likely yes, I have just set up a VM in FIPS mode and I start testing this on my environment.

> It's interesting that it works enabling fips at kernel level but not via
> envvars.(In reply to Timo Jyrinki from comment #23)
> 
> > That is not a real workaround in the sense that we have two ways of
> > supporting FIPS, the kernel mode and using the environment variables, and
> > both are expected to work. But yes, it's anyway very useful to narrow down
> > where things might go wrong.
> 
> I agree, at least we know that apache works in fips mode, therefore it seems
> something config-related or a silly issue somewhere.

Please, note that the support for the kernel FIPS mode can be enabled in two ways:
 1.- Add fips=1 on line GRUB_CMDLINE_LINUX_DEFAULT in file /etc/default/grub and execute following commands: zypper in -y -t pattern fips && grub2-mkconfig -o /boot/grub2/grub.cfg && mkinitrd && reboot

 2.- Use just one command from the crypto-policies-scripts package and reboot: fips-mode-setup --enable

Also, using forced FIPS mode for openssl with the envvar OPENSSL_FORCE_FIPS_MODE=1 should work as well. This is mostly used for testing the FIPS mode before enabling it.

So, from the previous comment it looks that the kernel FIPS mode has not been correctly enabled and that's probably why you mentioned its working there. Could you confirm? TIA
Comment 26 Timo Jyrinki 2024-04-03 09:15:26 UTC
(In reply to Pedro Monreal Gonzalez from comment #25)
> So, from the previous comment it looks that the kernel FIPS mode has not
> been correctly enabled and that's probably why you mentioned its working
> there. Could you confirm? TIA

Was this for me? For me and our testing, we're correctly enabling kernel FIPS mode. In this switching between kernel end env var mode in my manual testing, I had installed the fips pattern and added fips=1 via yast2 bootloader module.

In our automated testing where it also passes, we're using fips-mode-setup --enable from crypto-policies-scripts (reference: https://openqa.suse.de/tests/13914185#step/fips_setup/22).
Comment 27 Pedro Monreal Gonzalez 2024-04-03 11:12:10 UTC
(In reply to Timo Jyrinki from comment #26)
> (In reply to Pedro Monreal Gonzalez from comment #25)
> > So, from the previous comment it looks that the kernel FIPS mode has not
> > been correctly enabled and that's probably why you mentioned its working
> > there. Could you confirm? TIA
> 
> Was this for me? For me and our testing, we're correctly enabling kernel
> FIPS mode. In this switching between kernel end env var mode in my manual
> testing, I had installed the fips pattern and added fips=1 via yast2
> bootloader module.
> 
> In our automated testing where it also passes, we're using fips-mode-setup
> --enable from crypto-policies-scripts (reference:
> https://openqa.suse.de/tests/13914185#step/fips_setup/22).

Hi, Timo. I just don't understand why it fails in forced FIPS mode by using envvars and not in kernel FIPS mode, I think both should work the same. But, since I'm not familiar with enabling FIPS via yast2, I was wondering if all was done correctly. See also the SP5 documentation [0].

Could you check if doing this fails the same as with 'fips-mode-setup --enable && reboot'?:
  1.- run the command 'fips-mode-setup --disable'
  2.- reboot
  3.- use envvars only and start apache2

Thanks in advance!

[0] https://documentation.suse.com/sles/15-SP5/single-html/SLES-security/#sec-how-to-fips-install
Comment 28 Timo Jyrinki 2024-04-03 13:48:49 UTC
(In reply to Pedro Monreal Gonzalez from comment #27)
> Hi, Timo. I just don't understand why it fails in forced FIPS mode by using
> envvars and not in kernel FIPS mode

Yes, me neither :)

But we are testing both cases just because of the mechanism being different.

> I think both should work the same. But,
> since I'm not familiar with enabling FIPS via yast2, I was wondering if all
> was done correctly. See also the SP5 documentation [0].
> 
> Could you check if doing this fails the same as with 'fips-mode-setup
> --enable && reboot'?:
>   1.- run the command 'fips-mode-setup --disable'
>   2.- reboot
>   3.- use envvars only and start apache2

I was trying to explain we've covered all of these via either manual or automated testing, but just in case of doubt I did what you asked in the VM and the results say the same: after --disable (but env vars present) failing, while with FIPS kernel mode enabled not failing.

Again, the VM is available for easy transfering if you want to play around with it yourself.
Comment 29 Pedro Monreal Gonzalez 2024-04-03 14:45:43 UTC
Timo, thanks for double checking. Yes, please, give me and Otto access to the VM and we can take a look. TIA
Comment 30 Timo Jyrinki 2024-04-03 14:50:35 UTC
Ack, Otto has had it since last Thursday, now you have access as well.
Comment 31 Pedro Monreal Gonzalez 2024-04-03 15:38:01 UTC
(In reply to Timo Jyrinki from comment #30)
> Ack, Otto has had it since last Thursday, now you have access as well.

Thanks! I suspect there might be other libraries at play that are not in forced FIPS mode when the envvar for openssl is used. There could be NSS, GnuTLS, Libgcrypt... they can be forced similarly with:

 * LIBGCRYPT_FORCE_FIPS_MODE=1

I'll try this now!
Comment 32 Timo Jyrinki 2024-04-04 06:53:54 UTC
We always set the following env vars in our automated testing when using environment variables (in kernel fips mode, we do not set those):

OPENSSL_FIPS=1
OPENSSL_FORCE_FIPS_MODE=1
LIBGCRYPT_FORCE_FIPS_MODE=1
NSS_FIPS=1
GnuTLS_FORCE_FIPS_MODE=1

(in the VM I provided, I added them both to /etc/profile and /etc/bash.bashrc)
Comment 33 Radoslav Tzvetkov 2024-04-04 12:23:51 UTC
As I understand, Pedro provides the information. If so, I cleave the needinfo flag.

 We'll have an SR for this?
Comment 34 Pedro Monreal Gonzalez 2024-04-04 21:26:10 UTC
(In reply to Radoslav Tzvetkov from comment #33)
> As I understand, Pedro provides the information. If so, I cleave the
> needinfo flag.
> 
>  We'll have an SR for this?

The original segfault was fixed by David and I think he will submit the final fix once this is clear.

Unfortunately, I can't find the root cause of why it fails in forced FIPS mode and not in kernel FIPS mode. The answer should be in apache2 code or config files but I'm not familiar with the code.
Comment 35 Swayammitra Tripathy 2024-04-08 12:47:16 UTC
Hello David,

Could please provide SR.
Comment 36 David Anes 2024-04-09 07:03:58 UTC
(In reply to Swayammitra Tripathy from comment #35)
> Hello David,
> 
> Could please provide SR.

There is no fix yet to submit.
Comment 37 Radoslav Tzvetkov 2024-04-15 14:21:06 UTC
Do you have an estimate if it can be submitted before 17.04? This is a blocker issue for the PublicRC.
Comment 38 David Anes 2024-04-16 07:11:44 UTC
(In reply to Radoslav Tzvetkov from comment #37)
> Do you have an estimate if it can be submitted before 17.04? This is a
> blocker issue for the PublicRC.

Unfortunately I have no estimate. Let me contact Otto, he may know a bit more about FIPS than me.

Also, why is it a blocker? I mean, it works in FIPS mode as far as it's set system-wide via kernel parameter (it's not crashing anymore, as it was, and a MR was already sent that fixed that).

What's missing is using envvars to force OpenSSL to be in FIPS so Apache picks it up, but in this case apache cannot find any valid cipher. I still think it's a config issue, but I didn't find the cause.
Comment 39 Radoslav Tzvetkov 2024-04-16 09:09:21 UTC
Hello David, this bug is a blocker because it blocks QE tests, and not because of the FIPS. FIPS should be ready with the Q1.

Jan, as FIPS is irrelevant for GM, can we remove the blocker?
Comment 40 Radoslav Tzvetkov 2024-04-24 13:51:12 UTC
SR mentioned this was integrated into 15 SP6 PublicRC 04 2024
Comment 41 David Anes 2024-07-03 11:19:42 UTC
Summary as of today:

* The original segfault was long fixed and set to all affected codestreams.
* There is still no fix for "works in kernel FIPS mode but using envvars/config then OpenSSL doesn't provide ciphers".

Unfortunately, I don't know how to debug this issue neither I found the root cause.