summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJose Quaresma <quaresma.jose@gmail.com>2024-07-31 16:06:58 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-08-03 07:47:36 +0100
commit73f5bd99d243495a11111d8a436779788a8f59ff (patch)
tree7edbee622e5fd765f115fa971e2b1bc3f0be96c5
parent2f23bb60170666ffb58cddbfc9f7d0c683544435 (diff)
downloadpoky-73f5bd99d243495a11111d8a436779788a8f59ff.tar.gz
libssh2: disable-DSA-by-default
Backport the merged solution and drop the submited patch. (From OE-Core rev: f099cc0782db9c726eff151a11c1c59a1a22b3d7) Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-support/libssh2/libssh2/0001-disable-DSA-by-default.patch173
-rw-r--r--meta/recipes-support/libssh2/libssh2/0001-test-drop-ssh-dss-openssh_server-config.patch30
-rw-r--r--meta/recipes-support/libssh2/libssh2_1.11.0.bb2
3 files changed, 174 insertions, 31 deletions
diff --git a/meta/recipes-support/libssh2/libssh2/0001-disable-DSA-by-default.patch b/meta/recipes-support/libssh2/libssh2/0001-disable-DSA-by-default.patch
new file mode 100644
index 0000000000..1af40abb42
--- /dev/null
+++ b/meta/recipes-support/libssh2/libssh2/0001-disable-DSA-by-default.patch
@@ -0,0 +1,173 @@
1From 124ab98ed2f3ea6478dd04c7b6947720fef385d3 Mon Sep 17 00:00:00 2001
2From: Viktor Szakats <commit@vsz.me>
3Date: Tue, 30 Jul 2024 20:00:05 +0200
4Subject: [PATCH] disable DSA by default
5
6Also:
7- add `LIBSSH2_DSA_ENABLE` to enable it explicitly.
8- test the above option in CI.
9- say 'deprecated' in docs and public header.
10- disable DSA in the CI server config.
11 (OpenSSH 9.8 no longer builds with it by default)
12 https://www.openssh.com/txt/release-9.8
13 Patch-by: Jose Quaresma
14- disable more DSA code when not enabled.
15
16Fixes #1433
17Closes #1435
18
19Upstream-Status: Backport [https://github.com/libssh2/libssh2/commit/b7ab0faa70567a789419798fe079f5678ad4e156]
20
21Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
22---
23 docs/libssh2_knownhost_add.3 | 2 +-
24 docs/libssh2_knownhost_addc.3 | 2 +-
25 docs/libssh2_session_hostkey.3 | 2 +-
26 include/libssh2.h | 4 ++--
27 src/hostkey.c | 4 ++++
28 src/knownhost.c | 16 ++++++++++------
29 tests/openssh_server/sshd_config | 2 +-
30 7 files changed, 20 insertions(+), 12 deletions(-)
31
32diff --git a/docs/libssh2_knownhost_add.3 b/docs/libssh2_knownhost_add.3
33index d0af2b6d..2b529c2e 100644
34--- a/docs/libssh2_knownhost_add.3
35+++ b/docs/libssh2_knownhost_add.3
36@@ -50,7 +50,7 @@ LIBSSH2_KNOWNHOST_KEYENC_RAW or LIBSSH2_KNOWNHOST_KEYENC_BASE64.
37
38 The key is using one of these algorithms:
39 LIBSSH2_KNOWNHOST_KEY_RSA1, LIBSSH2_KNOWNHOST_KEY_SSHRSA or
40-LIBSSH2_KNOWNHOST_KEY_SSHDSS.
41+LIBSSH2_KNOWNHOST_KEY_SSHDSS (deprecated).
42
43 \fIstore\fP should point to a pointer that gets filled in to point to the
44 known host data after the addition. NULL can be passed if you do not care about
45diff --git a/docs/libssh2_knownhost_addc.3 b/docs/libssh2_knownhost_addc.3
46index 21367e11..f15f6ea9 100644
47--- a/docs/libssh2_knownhost_addc.3
48+++ b/docs/libssh2_knownhost_addc.3
49@@ -55,7 +55,7 @@ LIBSSH2_KNOWNHOST_KEYENC_RAW or LIBSSH2_KNOWNHOST_KEYENC_BASE64.
50
51 The key is using one of these algorithms:
52 LIBSSH2_KNOWNHOST_KEY_RSA1, LIBSSH2_KNOWNHOST_KEY_SSHRSA or
53-LIBSSH2_KNOWNHOST_KEY_SSHDSS.
54+LIBSSH2_KNOWNHOST_KEY_SSHDSS (deprecated).
55
56 \fIstore\fP should point to a pointer that gets filled in to point to the
57 known host data after the addition. NULL can be passed if you do not care about
58diff --git a/docs/libssh2_session_hostkey.3 b/docs/libssh2_session_hostkey.3
59index d57c7eab..0f0ee4c7 100644
60--- a/docs/libssh2_session_hostkey.3
61+++ b/docs/libssh2_session_hostkey.3
62@@ -14,7 +14,7 @@ Returns a pointer to the current host key, the value \fIlen\fP points to will
63 get the length of the key.
64
65 The value \fItype\fP points to the type of hostkey which is one of:
66-LIBSSH2_HOSTKEY_TYPE_RSA, LIBSSH2_HOSTKEY_TYPE_DSS, or
67+LIBSSH2_HOSTKEY_TYPE_RSA, LIBSSH2_HOSTKEY_TYPE_DSS (deprecated), or
68 LIBSSH2_HOSTKEY_TYPE_UNKNOWN.
69
70 .SH RETURN VALUE
71diff --git a/include/libssh2.h b/include/libssh2.h
72index 97ac5898..4c1faa53 100644
73--- a/include/libssh2.h
74+++ b/include/libssh2.h
75@@ -470,7 +470,7 @@ typedef struct _LIBSSH2_POLLFD {
76 /* Hostkey Types */
77 #define LIBSSH2_HOSTKEY_TYPE_UNKNOWN 0
78 #define LIBSSH2_HOSTKEY_TYPE_RSA 1
79-#define LIBSSH2_HOSTKEY_TYPE_DSS 2
80+#define LIBSSH2_HOSTKEY_TYPE_DSS 2 /* deprecated */
81 #define LIBSSH2_HOSTKEY_TYPE_ECDSA_256 3
82 #define LIBSSH2_HOSTKEY_TYPE_ECDSA_384 4
83 #define LIBSSH2_HOSTKEY_TYPE_ECDSA_521 5
84@@ -1094,7 +1094,7 @@ libssh2_knownhost_init(LIBSSH2_SESSION *session);
85 #define LIBSSH2_KNOWNHOST_KEY_SHIFT 18
86 #define LIBSSH2_KNOWNHOST_KEY_RSA1 (1<<18)
87 #define LIBSSH2_KNOWNHOST_KEY_SSHRSA (2<<18)
88-#define LIBSSH2_KNOWNHOST_KEY_SSHDSS (3<<18)
89+#define LIBSSH2_KNOWNHOST_KEY_SSHDSS (3<<18) /* deprecated */
90 #define LIBSSH2_KNOWNHOST_KEY_ECDSA_256 (4<<18)
91 #define LIBSSH2_KNOWNHOST_KEY_ECDSA_384 (5<<18)
92 #define LIBSSH2_KNOWNHOST_KEY_ECDSA_521 (6<<18)
93diff --git a/src/hostkey.c b/src/hostkey.c
94index f3823676..a5e07029 100644
95--- a/src/hostkey.c
96+++ b/src/hostkey.c
97@@ -1346,9 +1346,11 @@ static int hostkey_type(const unsigned char *hostkey, size_t len)
98 static const unsigned char rsa[] = {
99 0, 0, 0, 0x07, 's', 's', 'h', '-', 'r', 's', 'a'
100 };
101+#if LIBSSH2_DSA
102 static const unsigned char dss[] = {
103 0, 0, 0, 0x07, 's', 's', 'h', '-', 'd', 's', 's'
104 };
105+#endif
106 static const unsigned char ecdsa_256[] = {
107 0, 0, 0, 0x13, 'e', 'c', 'd', 's', 'a', '-', 's', 'h', 'a', '2', '-',
108 'n', 'i', 's', 't', 'p', '2', '5', '6'
109@@ -1371,8 +1373,10 @@ static int hostkey_type(const unsigned char *hostkey, size_t len)
110 if(!memcmp(rsa, hostkey, 11))
111 return LIBSSH2_HOSTKEY_TYPE_RSA;
112
113+#if LIBSSH2_DSA
114 if(!memcmp(dss, hostkey, 11))
115 return LIBSSH2_HOSTKEY_TYPE_DSS;
116+#endif
117
118 if(len < 15)
119 return LIBSSH2_HOSTKEY_TYPE_UNKNOWN;
120diff --git a/src/knownhost.c b/src/knownhost.c
121index c2231180..afa96508 100644
122--- a/src/knownhost.c
123+++ b/src/knownhost.c
124@@ -773,18 +773,20 @@ static int hostline(LIBSSH2_KNOWNHOSTS *hosts,
125 }
126 key_type_len = key - key_type_name;
127
128- if(!strncmp(key_type_name, "ssh-dss", key_type_len))
129- key_type = LIBSSH2_KNOWNHOST_KEY_SSHDSS;
130- else if(!strncmp(key_type_name, "ssh-rsa", key_type_len))
131- key_type = LIBSSH2_KNOWNHOST_KEY_SSHRSA;
132+ if(!strncmp(key_type_name, "ssh-ed25519", key_type_len))
133+ key_type = LIBSSH2_KNOWNHOST_KEY_ED25519;
134 else if(!strncmp(key_type_name, "ecdsa-sha2-nistp256", key_type_len))
135 key_type = LIBSSH2_KNOWNHOST_KEY_ECDSA_256;
136 else if(!strncmp(key_type_name, "ecdsa-sha2-nistp384", key_type_len))
137 key_type = LIBSSH2_KNOWNHOST_KEY_ECDSA_384;
138 else if(!strncmp(key_type_name, "ecdsa-sha2-nistp521", key_type_len))
139 key_type = LIBSSH2_KNOWNHOST_KEY_ECDSA_521;
140- else if(!strncmp(key_type_name, "ssh-ed25519", key_type_len))
141- key_type = LIBSSH2_KNOWNHOST_KEY_ED25519;
142+ else if(!strncmp(key_type_name, "ssh-rsa", key_type_len))
143+ key_type = LIBSSH2_KNOWNHOST_KEY_SSHRSA;
144+#if LIBSSH2_DSA
145+ else if(!strncmp(key_type_name, "ssh-dss", key_type_len))
146+ key_type = LIBSSH2_KNOWNHOST_KEY_SSHDSS;
147+#endif
148 else
149 key_type = LIBSSH2_KNOWNHOST_KEY_UNKNOWN;
150
151@@ -1020,10 +1022,12 @@ knownhost_writeline(LIBSSH2_KNOWNHOSTS *hosts,
152 key_type_name = "ssh-rsa";
153 key_type_len = 7;
154 break;
155+#if LIBSSH2_DSA
156 case LIBSSH2_KNOWNHOST_KEY_SSHDSS:
157 key_type_name = "ssh-dss";
158 key_type_len = 7;
159 break;
160+#endif
161 case LIBSSH2_KNOWNHOST_KEY_ECDSA_256:
162 key_type_name = "ecdsa-sha2-nistp256";
163 key_type_len = 19;
164diff --git a/tests/openssh_server/sshd_config b/tests/openssh_server/sshd_config
165index 1069566f..5cd2b898 100644
166--- a/tests/openssh_server/sshd_config
167+++ b/tests/openssh_server/sshd_config
168@@ -1,4 +1,4 @@
169 HostKeyAlgorithms +ssh-rsa
170-PubkeyAcceptedKeyTypes +ssh-rsa,ssh-dss,ssh-rsa-cert-v01@openssh.com
171+PubkeyAcceptedKeyTypes +ssh-rsa,ssh-rsa-cert-v01@openssh.com
172 MACs +hmac-sha1,hmac-sha1-96,hmac-sha2-256,hmac-sha2-512,hmac-md5,hmac-md5-96,umac-64@openssh.com,umac-128@openssh.com,hmac-sha1-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-md5-etm@openssh.com,hmac-md5-96-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com
173 Ciphers +3des-cbc,aes128-cbc,aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com
diff --git a/meta/recipes-support/libssh2/libssh2/0001-test-drop-ssh-dss-openssh_server-config.patch b/meta/recipes-support/libssh2/libssh2/0001-test-drop-ssh-dss-openssh_server-config.patch
deleted file mode 100644
index acab5c3776..0000000000
--- a/meta/recipes-support/libssh2/libssh2/0001-test-drop-ssh-dss-openssh_server-config.patch
+++ /dev/null
@@ -1,30 +0,0 @@
1From 3ba10a5fe090ef76e4dcb710d3f431a0caecc28d Mon Sep 17 00:00:00 2001
2From: Jose Quaresma <jose.quaresma@foundries.io>
3Date: Thu, 25 Jul 2024 14:02:00 +0100
4Subject: [PATCH] test: drop ssh-dss openssh_server config
5
6The ssh-dss was deprecated [1] in the OpenSSH 9.8p1
7
8Support for ssh-dss, ssh-dss-cert-* host and user keys is disabled
9by default at run-time. These may be re-enabled using the
10instructions at http://www.openssh.com/legacy.html
11
12[1] https://www.openssh.com/releasenotes.html
13
14Upstream-Status: Submitted [https://github.com/libssh2/libssh2/pull/1433]
15
16Signed-off-by: Jose Quaresma <jose.quaresma@foundries.io>
17---
18 tests/openssh_server/sshd_config | 2 +-
19 1 file changed, 1 insertion(+), 1 deletion(-)
20
21diff --git a/tests/openssh_server/sshd_config b/tests/openssh_server/sshd_config
22index 1069566f..5cd2b898 100644
23--- a/tests/openssh_server/sshd_config
24+++ b/tests/openssh_server/sshd_config
25@@ -1,4 +1,4 @@
26 HostKeyAlgorithms +ssh-rsa
27-PubkeyAcceptedKeyTypes +ssh-rsa,ssh-dss,ssh-rsa-cert-v01@openssh.com
28+PubkeyAcceptedKeyTypes +ssh-rsa,ssh-rsa-cert-v01@openssh.com
29 MACs +hmac-sha1,hmac-sha1-96,hmac-sha2-256,hmac-sha2-512,hmac-md5,hmac-md5-96,umac-64@openssh.com,umac-128@openssh.com,hmac-sha1-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-md5-etm@openssh.com,hmac-md5-96-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com
30 Ciphers +3des-cbc,aes128-cbc,aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com
diff --git a/meta/recipes-support/libssh2/libssh2_1.11.0.bb b/meta/recipes-support/libssh2/libssh2_1.11.0.bb
index d47fc44cbf..00ce940678 100644
--- a/meta/recipes-support/libssh2/libssh2_1.11.0.bb
+++ b/meta/recipes-support/libssh2/libssh2_1.11.0.bb
@@ -10,7 +10,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=24a33237426720395ebb1dd1349ca225"
10SRC_URI = "http://www.libssh2.org/download/${BP}.tar.gz \ 10SRC_URI = "http://www.libssh2.org/download/${BP}.tar.gz \
11 file://run-ptest \ 11 file://run-ptest \
12 file://CVE-2023-48795.patch \ 12 file://CVE-2023-48795.patch \
13 file://0001-test-drop-ssh-dss-openssh_server-config.patch \ 13 file://0001-disable-DSA-by-default.patch \
14 " 14 "
15 15
16SRC_URI[sha256sum] = "3736161e41e2693324deb38c26cfdc3efe6209d634ba4258db1cecff6a5ad461" 16SRC_URI[sha256sum] = "3736161e41e2693324deb38c26cfdc3efe6209d634ba4258db1cecff6a5ad461"