Enable GSS KEX in FIPS mode

This commit is contained in:
Dmitry Belyavskiy 2025-08-28 14:07:02 +02:00
commit 6fcc31aa4a
2 changed files with 68 additions and 115 deletions

View file

@ -1,7 +1,7 @@
From 6e0e7462959e8bc6a99f50dbf9a5b42ae74c2c87 Mon Sep 17 00:00:00 2001
From 79f9b2763d85ec592cb7e54dcf1c695d8dd138b1 Mon Sep 17 00:00:00 2001
From: Dmitry Belyavskiy <beldmit@gmail.com>
Date: Thu, 15 May 2025 13:43:29 +0200
Subject: [PATCH 42/50] openssh-7.7p1-fips
Date: Thu, 28 Aug 2025 14:01:38 +0200
Subject: [PATCH 42/54] openssh-7.7p1-fips
---
dh.c | 41 ++++++++++++++++++++++
@ -15,17 +15,18 @@ Subject: [PATCH 42/50] openssh-7.7p1-fips
sandbox-seccomp-filter.c | 3 ++
servconf.c | 16 ++++++---
ssh-ed25519.c | 9 +++++
ssh-gss.h | 5 +++
ssh-keygen.c | 22 ++++++++++--
ssh-rsa.c | 3 ++
ssh.c | 5 +++
sshconnect2.c | 61 ++++++++++++++++++---------------
sshd-auth.c | 13 ++++---
sshconnect2.c | 9 ++++-
sshd-session.c | 1 +
sshd.c | 13 +++++++
sshkey.c | 37 ++++++++++++++++++++
18 files changed, 301 insertions(+), 60 deletions(-)
19 files changed, 272 insertions(+), 30 deletions(-)
diff --git a/dh.c b/dh.c
index 168dea1d..8c9a29fa 100644
index 168dea1dd..8c9a29fa7 100644
--- a/dh.c
+++ b/dh.c
@@ -36,6 +36,7 @@
@ -89,7 +90,7 @@ index 168dea1d..8c9a29fa 100644
+
#endif /* WITH_OPENSSL */
diff --git a/dh.h b/dh.h
index c6326a39..e51e292b 100644
index c6326a39d..e51e292b8 100644
--- a/dh.h
+++ b/dh.h
@@ -45,6 +45,7 @@ DH *dh_new_group_fallback(int);
@ -101,7 +102,7 @@ index c6326a39..e51e292b 100644
u_int dh_estimate(int);
void dh_set_moduli_file(const char *);
diff --git a/kex-names.c b/kex-names.c
index 6c0b7c2b..cd3902ad 100644
index 6c0b7c2b3..cd3902ad2 100644
--- a/kex-names.c
+++ b/kex-names.c
@@ -33,6 +33,7 @@
@ -125,7 +126,7 @@ index 6c0b7c2b..cd3902ad 100644
return 0;
}
diff --git a/kex.c b/kex.c
index 62f607d6..71fbe5cb 100644
index 62f607d6f..71fbe5cbe 100644
--- a/kex.c
+++ b/kex.c
@@ -40,6 +40,7 @@
@ -146,7 +147,7 @@ index 62f607d6..71fbe5cb 100644
"ext-info-s,kex-strict-s-v00@openssh.com" :
"ext-info-c,kex-strict-c-v00@openssh.com")) == NULL)
diff --git a/kexgen.c b/kexgen.c
index 15df591c..eecdceba 100644
index 15df591ca..eecdceba2 100644
--- a/kexgen.c
+++ b/kexgen.c
@@ -31,6 +31,7 @@
@ -264,7 +265,7 @@ index 15df591c..eecdceba 100644
default:
r = SSH_ERR_INVALID_ARGUMENT;
diff --git a/kexgexc.c b/kexgexc.c
index e99e0cf2..4c3feae0 100644
index e99e0cf21..4c3feae09 100644
--- a/kexgexc.c
+++ b/kexgexc.c
@@ -28,6 +28,7 @@
@ -287,7 +288,7 @@ index e99e0cf2..4c3feae0 100644
/* generate and send 'e', client DH public key */
diff --git a/myproposal.h b/myproposal.h
index 8fe9276c..3e0ec682 100644
index 8fe9276c2..3e0ec6826 100644
--- a/myproposal.h
+++ b/myproposal.h
@@ -58,6 +58,18 @@
@ -338,7 +339,7 @@ index 8fe9276c..3e0ec682 100644
#define SSH_ALLOWED_CA_SIGALGS \
"ssh-ed25519," \
diff --git a/readconf.c b/readconf.c
index f340bf50..ea9d293c 100644
index f340bf501..ea9d293c3 100644
--- a/readconf.c
+++ b/readconf.c
@@ -43,6 +43,7 @@
@ -372,7 +373,7 @@ index f340bf50..ea9d293c 100644
do { \
if ((r = kex_assemble_names(&options->what, \
diff --git a/sandbox-seccomp-filter.c b/sandbox-seccomp-filter.c
index 1fabf99d..ccb61586 100644
index 1fabf99d0..ccb61586e 100644
--- a/sandbox-seccomp-filter.c
+++ b/sandbox-seccomp-filter.c
@@ -230,6 +230,9 @@ static const struct sock_filter preauth_insns[] = {
@ -386,7 +387,7 @@ index 1fabf99d..ccb61586 100644
SC_DENY(__NR_openat, EACCES),
#endif
diff --git a/servconf.c b/servconf.c
index 84891544..8b708cbf 100644
index 84891544b..8b708cbf4 100644
--- a/servconf.c
+++ b/servconf.c
@@ -37,6 +37,7 @@
@ -420,7 +421,7 @@ index 84891544..8b708cbf 100644
do { \
if ((r = kex_assemble_names(&o->what, defaults, all)) != 0) \
diff --git a/ssh-ed25519.c b/ssh-ed25519.c
index 22d8db02..41942f4e 100644
index 22d8db026..41942f4e5 100644
--- a/ssh-ed25519.c
+++ b/ssh-ed25519.c
@@ -24,6 +24,7 @@
@ -453,8 +454,24 @@ index 22d8db02..41942f4e 100644
if ((b = sshbuf_from(sig, siglen)) == NULL)
return SSH_ERR_ALLOC_FAIL;
diff --git a/ssh-gss.h b/ssh-gss.h
index a894e23c9..329dc9da0 100644
--- a/ssh-gss.h
+++ b/ssh-gss.h
@@ -88,6 +88,11 @@ extern char **k5users_allowed_cmds;
KEX_GSS_GRP14_SHA1_ID "," \
KEX_GSS_GEX_SHA1_ID
+#define GSS_KEX_DEFAULT_KEX_FIPS \
+ KEX_GSS_GRP14_SHA256_ID "," \
+ KEX_GSS_GRP16_SHA512_ID "," \
+ KEX_GSS_NISTP256_SHA256_ID
+
#include "digest.h" /* SSH_DIGEST_MAX_LENGTH */
typedef struct {
diff --git a/ssh-keygen.c b/ssh-keygen.c
index 16cff947..792aafde 100644
index 16cff9473..792aafde0 100644
--- a/ssh-keygen.c
+++ b/ssh-keygen.c
@@ -20,6 +20,7 @@
@ -524,7 +541,7 @@ index 16cff947..792aafde 100644
type = sshkey_type_from_shortname(key_type_name);
type_bits_valid(type, key_type_name, &bits);
diff --git a/ssh-rsa.c b/ssh-rsa.c
index 3ad1fddc..6c2f771a 100644
index 3ad1fddc4..6c2f771a3 100644
--- a/ssh-rsa.c
+++ b/ssh-rsa.c
@@ -23,6 +23,7 @@
@ -545,7 +562,7 @@ index 3ad1fddc..6c2f771a 100644
goto out;
}
diff --git a/ssh.c b/ssh.c
index 98b103c9..abc8b843 100644
index 98b103c9e..abc8b8439 100644
--- a/ssh.c
+++ b/ssh.c
@@ -78,6 +78,7 @@
@ -568,7 +585,7 @@ index 98b103c9..abc8b843 100644
if (options.sk_provider != NULL && *options.sk_provider == '$' &&
strlen(options.sk_provider) > 1) {
diff --git a/sshconnect2.c b/sshconnect2.c
index 0af15bcc..14f7671a 100644
index 0af15bcc1..3e02f485d 100644
--- a/sshconnect2.c
+++ b/sshconnect2.c
@@ -45,6 +45,8 @@
@ -580,108 +597,41 @@ index 0af15bcc..14f7671a 100644
#include "openbsd-compat/sys-queue.h"
#include "xmalloc.h"
@@ -262,36 +264,41 @@ ssh_kex2(struct ssh *ssh, char *host, struct sockaddr *hostaddr, u_short port,
@@ -262,6 +264,9 @@ ssh_kex2(struct ssh *ssh, char *host, struct sockaddr *hostaddr, u_short port,
#if defined(GSSAPI) && defined(WITH_OPENSSL)
if (options.gss_keyex) {
- /* Add the GSSAPI mechanisms currently supported on this
- * client to the key exchange algorithm proposal */
- orig = myproposal[PROPOSAL_KEX_ALGS];
-
- if (options.gss_server_identity) {
- gss_host = xstrdup(options.gss_server_identity);
- } else if (options.gss_trust_dns) {
- gss_host = remote_hostname(ssh);
- /* Fall back to specified host if we are using proxy command
- * and can not use DNS on that socket */
- if (strcmp(gss_host, "UNKNOWN") == 0) {
- free(gss_host);
+ if (FIPS_mode()) {
+ logit("Disabling GSSAPIKeyExchange. Not usable in FIPS mode");
+ options.gss_keyex = 0;
+ } else {
+ /* Add the GSSAPI mechanisms currently supported on this
+ * client to the key exchange algorithm proposal */
+ orig = myproposal[PROPOSAL_KEX_ALGS];
+ char * gss_kex_filtered = FIPS_mode() ?
+ match_filter_allowlist(options.gss_kex_algorithms, GSS_KEX_DEFAULT_KEX_FIPS) : xstrdup(options.gss_kex_algorithms);
+
+ if (options.gss_server_identity) {
+ gss_host = xstrdup(options.gss_server_identity);
+ } else if (options.gss_trust_dns) {
+ gss_host = remote_hostname(ssh);
+ /* Fall back to specified host if we are using proxy command
+ * and can not use DNS on that socket */
+ if (strcmp(gss_host, "UNKNOWN") == 0) {
+ free(gss_host);
+ gss_host = xstrdup(host);
+ }
+ } else {
gss_host = xstrdup(host);
}
- } else {
- gss_host = xstrdup(host);
- }
- gss = ssh_gssapi_client_mechanisms(gss_host,
- options.gss_client_identity, options.gss_kex_algorithms);
- if (gss) {
- debug("Offering GSSAPI proposal: %s", gss);
- xasprintf(&myproposal[PROPOSAL_KEX_ALGS],
- "%s,%s", gss, orig);
-
- /* If we've got GSSAPI algorithms, then we also support the
- * 'null' hostkey, as a last resort */
- orig = myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS];
- xasprintf(&myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS],
- "%s,null", orig);
+ gss = ssh_gssapi_client_mechanisms(gss_host,
+ options.gss_client_identity, options.gss_kex_algorithms);
+ if (gss) {
+ debug("Offering GSSAPI proposal: %s", gss);
+ xasprintf(&myproposal[PROPOSAL_KEX_ALGS],
+ "%s,%s", gss, orig);
+
+ /* If we've got GSSAPI algorithms, then we also support the
+ * 'null' hostkey, as a last resort */
+ orig = myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS];
+ xasprintf(&myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS],
+ "%s,null", orig);
+ }
/* Add the GSSAPI mechanisms currently supported on this
* client to the key exchange algorithm proposal */
orig = myproposal[PROPOSAL_KEX_ALGS];
@@ -281,7 +286,9 @@ ssh_kex2(struct ssh *ssh, char *host, struct sockaddr *hostaddr, u_short port,
}
}
#endif
diff --git a/sshd-auth.c b/sshd-auth.c
index 897db9b4..eaf32981 100644
--- a/sshd-auth.c
+++ b/sshd-auth.c
@@ -58,6 +58,7 @@
#ifdef WITH_OPENSSL
gss = ssh_gssapi_client_mechanisms(gss_host,
- options.gss_client_identity, options.gss_kex_algorithms);
+ options.gss_client_identity, gss_kex_filtered);
+ free(gss_kex_filtered);
+
if (gss) {
debug("Offering GSSAPI proposal: %s", gss);
xasprintf(&myproposal[PROPOSAL_KEX_ALGS],
diff --git a/sshd-session.c b/sshd-session.c
index a808ac9a6..a67a78391 100644
--- a/sshd-session.c
+++ b/sshd-session.c
@@ -62,6 +62,7 @@
#include <openssl/bn.h>
#include <openssl/evp.h>
#include <openssl/rand.h>
+#include <openssl/fips.h>
#include "openbsd-compat/openssl-compat.h"
#endif
#include "xmalloc.h"
@@ -859,10 +860,14 @@ do_ssh2_kex(struct ssh *ssh)
if (strlen(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS]) == 0)
orig = NULL;
- if (options.gss_keyex)
- gss = ssh_gssapi_server_mechanisms();
- else
- gss = NULL;
+ if (options.gss_keyex) {
+ if (FIPS_mode()) {
+ logit("Disabling GSSAPIKeyExchange. Not usable in FIPS mode");
+ options.gss_keyex = 0;
+ } else {
+ gss = ssh_gssapi_server_mechanisms();
+ }
+ }
if (gss && orig)
xasprintf(&newstr, "%s,%s", gss, orig);
diff --git a/sshd.c b/sshd.c
index 8a99f0b2..5ff0b5ff 100644
index 8a99f0b29..5ff0b5ff0 100644
--- a/sshd.c
+++ b/sshd.c
@@ -52,6 +52,7 @@
@ -726,7 +676,7 @@ index 8a99f0b2..5ff0b5ff 100644
* Chdir to the root directory so that the current disk can be
* unmounted if desired.
diff --git a/sshkey.c b/sshkey.c
index 4e41a78c..ca1cdb64 100644
index 4e41a78c7..ca1cdb642 100644
--- a/sshkey.c
+++ b/sshkey.c
@@ -35,6 +35,7 @@
@ -809,5 +759,5 @@ index 4e41a78c..ca1cdb64 100644
return SSH_ERR_KEY_TYPE_UNKNOWN;
return impl->funcs->verify(key, sig, siglen, data, dlen,
--
2.49.0
2.51.0

View file

@ -43,7 +43,7 @@
Summary: An open source implementation of SSH protocol version 2
Name: openssh
Version: %{openssh_ver}
Release: 5%{?dist}
Release: 6%{?dist}
URL: http://www.openssh.com/portable.html
Source0: ftp://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-%{version}.tar.gz
Source1: ftp://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-%{version}.tar.gz.asc
@ -586,6 +586,9 @@ test -f %{sysconfig_anaconda} && \
%attr(0755,root,root) %{_libdir}/sshtest/sk-dummy.so
%changelog
* Thu Aug 28 2025 Dmitry Belyavskiy <dbelyavs@redhat.com> - 10.0p1-6
- Enable GSS KEX in FIPS mode
* Thu Jul 24 2025 Fedora Release Engineering <releng@fedoraproject.org> - 10.0p1-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild