Skip to content

Commit 1074c16

Browse files
committed
[PA-6132] : Applied CVE patched for openssl-1.1.1k-6. Following patches were applied:
1. CVE-2023-3446 2. CVE-2023-5678 3. CVE-2024-0727
1 parent 83ca2f8 commit 1074c16

File tree

5 files changed

+350
-19
lines changed

5 files changed

+350
-19
lines changed

configs/components/openssl-1.1.1-fips.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
pkg.add_source 'file://resources/patches/openssl/openssl-1.1.1-fips-spec-file.patch'
2525
pkg.add_source 'file://resources/patches/openssl/openssl-1.1.1-fips-remove-env-check.patch'
2626
pkg.add_source 'file://resources/patches/openssl/openssl-1.1.1l-sm2-plaintext.patch'
27+
pkg.add_source 'file://resources/patches/openssl/openssl-1.1.1k-CVE-2023-3446-fips.patch'
28+
pkg.add_source 'file://resources/patches/openssl/openssl-1.1.1k-CVE-2023-5678-fips.patch'
29+
pkg.add_source 'file://resources/patches/openssl/openssl-1.1.1k-CVE-2024-0727-fips.patch'
2730

2831
if platform.name =~ /-7-/
2932
pkg.add_source 'file://resources/patches/openssl/openssl-1.1.1-fips-post-rand.patch'
@@ -55,7 +58,10 @@
5558
"cd openssl-#{pkg.get_version} && /usr/bin/patch --strip=1 --fuzz=0 --ignore-whitespace --no-backup-if-mismatch < ../openssl-1.1.1-fips-force-fips-mode.patch && cd -",
5659
"cd openssl-#{pkg.get_version} && /usr/bin/patch --strip=1 --fuzz=0 --ignore-whitespace --no-backup-if-mismatch < ../openssl-1.1.1-fips-spec-file.patch && cd -",
5760
"cd openssl-#{pkg.get_version} && /usr/bin/patch --strip=1 --fuzz=0 --ignore-whitespace --no-backup-if-mismatch < ../openssl-1.1.1-fips-remove-env-check.patch && cd -",
58-
"cd openssl-#{pkg.get_version} && /usr/bin/patch --strip=1 --fuzz=0 --ignore-whitespace --no-backup-if-mismatch < ../openssl-1.1.1l-sm2-plaintext.patch && cd -"
61+
"cd openssl-#{pkg.get_version} && /usr/bin/patch --strip=1 --fuzz=0 --ignore-whitespace --no-backup-if-mismatch < ../openssl-1.1.1l-sm2-plaintext.patch && cd -",
62+
"cd openssl-#{pkg.get_version} && /usr/bin/patch --strip=1 --fuzz=0 --ignore-whitespace --no-backup-if-mismatch < ../openssl-1.1.1k-CVE-2023-3446-fips.patch && cd -",
63+
"cd openssl-#{pkg.get_version} && /usr/bin/patch --strip=1 --fuzz=0 --ignore-whitespace --no-backup-if-mismatch < ../openssl-1.1.1k-CVE-2023-5678-fips.patch && cd -",
64+
"cd openssl-#{pkg.get_version} && /usr/bin/patch --strip=1 --fuzz=0 --ignore-whitespace --no-backup-if-mismatch < ../openssl-1.1.1k-CVE-2024-0727-fips.patch && cd -"
5965
]
6066
end
6167

resources/patches/openssl/openssl-1.1.1-fips-spec-file.patch

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
--- a/SPECS/openssl.spec 2019-05-11 00:45:45.000000000 +0000
22
+++ b/SPECS/openssl.spec 2020-01-13 15:16:29.224852120 +0000
3-
@@ -83,16 +83,20 @@
3+
@@ -83,16 +83,23 @@
44
Patch75: openssl-1.1.1-tls13-curves.patch
55
Patch81: openssl-1.1.1-read-buff.patch
66
Patch82: openssl-1.1.1-cve-2022-0778.patch
77
+Patch100: openssl-1.1.1-force-fips-on-init.patch
88
+Patch101: openssl-1.1.1-openssl-cnf-fips-mode.patch
99
+Patch102: openssl-1.1.1-remove-env-check.patch
1010
+Patch103: openssl-1.1.1l-sm2-plaintext.patch
11+
+Patch104: openssl-1.1.1k-CVE-2023-3446-fips.patch
12+
+Patch105: openssl-1.1.1k-CVE-2023-5678-fips.patch
13+
+Patch106: openssl-1.1.1k-CVE-2024-0727-fips.patch
1114

1215
License: OpenSSL and ASL 2.0
1316
URL: http://www.openssl.org/
@@ -23,15 +26,15 @@
2326
BuildRequires: perl(Module::Load::Conditional), perl(File::Temp)
2427
BuildRequires: perl(Time::HiRes)
2528
BuildRequires: perl(FindBin), perl(lib), perl(File::Compare), perl(File::Copy)
26-
@@ -107,7 +112,6 @@
29+
@@ -109,7 +116,6 @@
2730
Summary: A general purpose cryptography library with TLS implementation
2831
Requires: ca-certificates >= 2008-5
2932
Requires: crypto-policies >= 20180730
3033
-Recommends: openssl-pkcs11%{?_isa}
3134
# Needed obsoletes due to the base/lib subpackage split
3235
Obsoletes: openssl < 1:1.0.1-0.3.beta3
3336
Obsoletes: openssl-fips < 1:1.0.1e-28
34-
@@ -141,7 +145,7 @@
37+
@@ -143,7 +149,7 @@
3538

3639
%package perl
3740
Summary: Perl scripts provided with OpenSSL
@@ -40,18 +43,22 @@
4043
Requires: %{name}%{?_isa} = %{epoch}:%{version}-%{release}
4144

4245
%description perl
43-
@@ -208,6 +215,10 @@
46+
@@ -204,7 +210,13 @@
4447
%patch80 -p1 -b .s390x-test-aes
4548
%patch81 -p1 -b .read-buff
4649
%patch82 -p1 -b .cve-2022-0778
50+
-
4751
+%patch100 -p1 -b .force-fips-on-init
4852
+%patch101 -p1 -b .openssl-cnf-fips-mode
4953
+%patch102 -p1 -b .remove-env-check
5054
+%patch103 -p1 -b .sm2-plaintext
51-
55+
+%patch104 -p1 -F2 -b .CVE-2023-3446-fips
56+
+%patch105 -p1 -F2 -b .CVE-2023-5678-fips
57+
+%patch106 -p1 -b .CVE-2024-0727-fips
5258

5359
%build
54-
@@ -266,7 +275,7 @@
60+
# Figure out which flags we want to use.
61+
@@ -270,7 +282,7 @@
5562
# marked as not requiring an executable stack.
5663
# Also add -DPURIFY to make using valgrind with openssl easier as we do not
5764
# want to depend on the uninitialized memory as a source of entropy anyway.
@@ -60,18 +67,18 @@
6067

6168
export HASHBANGPERL=/usr/bin/perl
6269

63-
@@ -275,8 +284,8 @@
70+
@@ -279,8 +291,8 @@
6471
# usable on all platforms. The Configure script already knows to use -fPIC and
6572
# RPM_OPT_FLAGS, so we can skip specifiying them here.
6673
./Configure \
67-
- --prefix=%{_prefix} --openssldir=%{_sysconfdir}/pki/tls ${sslflags} \
68-
- --system-ciphers-file=%{_sysconfdir}/crypto-policies/back-ends/openssl.config \
69-
+ --prefix=%{_prefix} --openssldir=%{_prefix}/ssl ${sslflags} \
70-
+ --system-ciphers-file=%{_prefix}/etc/crypto-policies/back-ends/openssl.config \
71-
zlib enable-camellia enable-seed enable-rfc3779 enable-sctp \
72-
enable-cms enable-md2 enable-rc5\
73-
enable-weak-ssl-ciphers \
74-
@@ -348,14 +357,14 @@
74+
- --prefix=%{_prefix} --openssldir=%{_sysconfdir}/pki/tls ${sslflags} \
75+
- --system-ciphers-file=%{_sysconfdir}/crypto-policies/back-ends/openssl.config \
76+
+ --prefix=%{_prefix} --openssldir=%{_prefix}/ssl ${sslflags} \
77+
+ --system-ciphers-file=%{_prefix}/etc/crypto-policies/back-ends/openssl.config \
78+
zlib enable-camellia enable-seed enable-rfc3779 enable-sctp \
79+
enable-cms enable-md2 enable-rc5\
80+
enable-weak-ssl-ciphers \
81+
@@ -352,14 +364,14 @@
7582

7683
# Install a makefile for generating keys and self-signed certs, and a script
7784
# for generating them on the fly.
@@ -89,7 +96,7 @@
8996

9097
# Drop the SSLv3 methods from includes
9198
sed -i '/ifndef OPENSSL_NO_SSL3_METHOD/,+4d' $RPM_BUILD_ROOT%{_includedir}/openssl/ssl.h
92-
@@ -382,19 +391,19 @@
99+
@@ -386,19 +398,19 @@
93100
done
94101
popd
95102

@@ -118,7 +125,7 @@
118125

119126
# Determine which arch opensslconf.h is going to try to #include.
120127
basearch=%{_arch}
121-
@@ -441,12 +450,12 @@
128+
@@ -445,12 +457,12 @@
122129
%files libs
123130
%{!?_licensedir:%global license %%doc}
124131
%license LICENSE
@@ -137,7 +144,7 @@
137144
%attr(0755,root,root) %{_libdir}/libcrypto.so.%{version}
138145
%attr(0755,root,root) %{_libdir}/libcrypto.so.%{soversion}
139146
%attr(0755,root,root) %{_libdir}/libssl.so.%{version}
140-
@@ -473,11 +482,11 @@
147+
@@ -477,11 +489,11 @@
141148
%{_mandir}/man1*/c_rehash*
142149
%{_mandir}/man1*/tsget*
143150
%{_mandir}/man1*/openssl-tsget*
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
--- /dev/null 2024-02-22 20:27:57
2+
+++ openssl-1.1.1k/SOURCES/openssl-1.1.1k-CVE-2023-3446-fips.patch 2024-02-22 20:24:39
3+
@@ -0,0 +1,50 @@
4+
+diff --git a/crypto/dh/dh_err.c b/crypto/dh/dh_err.c
5+
+index 7285587b4a..8dd8ca0f92 100644
6+
+--- a/crypto/dh/dh_err.c
7+
++++ b/crypto/dh/dh_err.c
8+
+@@ -18,6 +18,7 @@ static const ERR_STRING_DATA DH_str_functs[] = {
9+
+ {ERR_PACK(ERR_LIB_DH, DH_F_DHPARAMS_PRINT_FP, 0), "DHparams_print_fp"},
10+
+ {ERR_PACK(ERR_LIB_DH, DH_F_DH_BUILTIN_GENPARAMS, 0),
11+
+ "dh_builtin_genparams"},
12+
++ {ERR_PACK(ERR_LIB_DH, DH_F_DH_CHECK, 0), "DH_check"},
13+
+ {ERR_PACK(ERR_LIB_DH, DH_F_DH_CHECK_EX, 0), "DH_check_ex"},
14+
+ {ERR_PACK(ERR_LIB_DH, DH_F_DH_CHECK_PARAMS_EX, 0), "DH_check_params_ex"},
15+
+ {ERR_PACK(ERR_LIB_DH, DH_F_DH_CHECK_PUB_KEY_EX, 0), "DH_check_pub_key_ex"},
16+
+diff --git a/crypto/err/openssl.txt b/crypto/err/openssl.txt
17+
+index 7e1776375d..df2fc4e830 100644
18+
+--- a/crypto/err/openssl.txt
19+
++++ b/crypto/err/openssl.txt
20+
+@@ -401,6 +401,7 @@ CT_F_SCT_SET_VERSION:104:SCT_set_version
21+
+ DH_F_COMPUTE_KEY:102:compute_key
22+
+ DH_F_DHPARAMS_PRINT_FP:101:DHparams_print_fp
23+
+ DH_F_DH_BUILTIN_GENPARAMS:106:dh_builtin_genparams
24+
++DH_F_DH_CHECK:126:DH_check
25+
+ DH_F_DH_CHECK_EX:121:DH_check_ex
26+
+ DH_F_DH_CHECK_PARAMS_EX:122:DH_check_params_ex
27+
+ DH_F_DH_CHECK_PUB_KEY_EX:123:DH_check_pub_key_ex
28+
+diff --git a/include/openssl/dh.h b/include/openssl/dh.h
29+
+index 3527540cdd..892e31559d 100644
30+
+--- a/include/openssl/dh.h
31+
++++ b/include/openssl/dh.h
32+
+@@ -29,6 +29,9 @@ extern "C" {
33+
+ # ifndef OPENSSL_DH_MAX_MODULUS_BITS
34+
+ # define OPENSSL_DH_MAX_MODULUS_BITS 10000
35+
+ # endif
36+
++# ifndef OPENSSL_DH_CHECK_MAX_MODULUS_BITS
37+
++# define OPENSSL_DH_CHECK_MAX_MODULUS_BITS 32768
38+
++# endif
39+
+
40+
+ # define OPENSSL_DH_FIPS_MIN_MODULUS_BITS 1024
41+
+
42+
+diff --git a/include/openssl/dherr.h b/include/openssl/dherr.h
43+
+index 916b3bed0b..9955f24652 100644
44+
+--- a/include/openssl/dherr.h
45+
++++ b/include/openssl/dherr.h
46+
+@@ -30,6 +30,7 @@ int ERR_load_DH_strings(void);
47+
+ # define DH_F_COMPUTE_KEY 102
48+
+ # define DH_F_DHPARAMS_PRINT_FP 101
49+
+ # define DH_F_DH_BUILTIN_GENPARAMS 106
50+
++# define DH_F_DH_CHECK 126
51+
+ # define DH_F_DH_CHECK_EX 121
52+
+ # define DH_F_DH_CHECK_PARAMS_EX 122
53+
+ # define DH_F_DH_CHECK_PUB_KEY_EX 123
54+
+
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
--- /dev/null 2024-02-26 19:17:51
2+
+++ openssl-1.1.1k-6/SOURCES/openssl-1.1.1k-CVE-2023-5678-fips.patch 2024-02-01 02:02:19
3+
@@ -0,0 +1,142 @@
4+
+Backport of:
5+
+
6+
+From db925ae2e65d0d925adef429afc37f75bd1c2017 Mon Sep 17 00:00:00 2001
7+
+From: Richard Levitte <[email protected]>
8+
+Date: Fri, 20 Oct 2023 09:18:19 +0200
9+
+Subject: [PATCH] Make DH_check_pub_key() and DH_generate_key() safer yet
10+
+
11+
+We already check for an excessively large P in DH_generate_key(), but not in
12+
+DH_check_pub_key(), and none of them check for an excessively large Q.
13+
+
14+
+This change adds all the missing excessive size checks of P and Q.
15+
+
16+
+It's to be noted that behaviours surrounding excessively sized P and Q
17+
+differ. DH_check() raises an error on the excessively sized P, but only
18+
+sets a flag for the excessively sized Q. This behaviour is mimicked in
19+
+DH_check_pub_key().
20+
+
21+
+Reviewed-by: Tomas Mraz <[email protected]>
22+
+Reviewed-by: Matt Caswell <[email protected]>
23+
+Reviewed-by: Hugo Landau <[email protected]>
24+
+(Merged from https://github.com/openssl/openssl/pull/22518)
25+
+
26+
+(cherry picked from commit ddeb4b6c6d527e54ce9a99cba785c0f7776e54b6)
27+
+---
28+
+ crypto/dh/dh_check.c | 12 ++++++++++++
29+
+ crypto/dh/dh_err.c | 3 ++-
30+
+ crypto/dh/dh_key.c | 12 ++++++++++++
31+
+ crypto/err/openssl.txt | 1 +
32+
+ include/crypto/dherr.h | 2 +-
33+
+ include/openssl/dh.h | 6 +++---
34+
+ include/openssl/dherr.h | 3 ++-
35+
+ 7 files changed, 33 insertions(+), 6 deletions(-)
36+
+
37+
+--- a/crypto/dh/dh_check.c
38+
++++ b/crypto/dh/dh_check.c
39+
+@@ -201,6 +201,19 @@ int DH_check_pub_key(const DH *dh, const
40+
+ if (ctx == NULL)
41+
+ goto err;
42+
+ BN_CTX_start(ctx);
43+
++
44+
++ /* Don't do any checks at all with an excessively large modulus */
45+
++ if (BN_num_bits(dh->p) > OPENSSL_DH_CHECK_MAX_MODULUS_BITS) {
46+
++ DHerr(DH_F_DH_CHECK, DH_R_MODULUS_TOO_LARGE);
47+
++ *ret = DH_MODULUS_TOO_LARGE | DH_CHECK_PUBKEY_INVALID;
48+
++ goto err;
49+
++ }
50+
++
51+
++ if (dh->q != NULL && BN_ucmp(dh->p, dh->q) < 0) {
52+
++ *ret |= DH_CHECK_INVALID_Q_VALUE | DH_CHECK_PUBKEY_INVALID;
53+
++ goto out;
54+
++ }
55+
++
56+
+ tmp = BN_CTX_get(ctx);
57+
+ if (tmp == NULL || !BN_set_word(tmp, 1))
58+
+ goto err;
59+
+@@ -219,6 +232,7 @@ int DH_check_pub_key(const DH *dh, const
60+
+ *ret |= DH_CHECK_PUBKEY_INVALID;
61+
+ }
62+
+
63+
++ out:
64+
+ ok = 1;
65+
+ err:
66+
+ BN_CTX_end(ctx);
67+
+--- a/crypto/dh/dh_err.c
68+
++++ b/crypto/dh/dh_err.c
69+
+@@ -82,6 +82,7 @@ static const ERR_STRING_DATA DH_str_reas
70+
+ {ERR_PACK(ERR_LIB_DH, 0, DH_R_PARAMETER_ENCODING_ERROR),
71+
+ "parameter encoding error"},
72+
+ {ERR_PACK(ERR_LIB_DH, 0, DH_R_PEER_KEY_ERROR), "peer key error"},
73+
++ {ERR_PACK(ERR_LIB_DH, 0, DH_R_Q_TOO_LARGE), "q too large"},
74+
+ {ERR_PACK(ERR_LIB_DH, 0, DH_R_SHARED_INFO_ERROR), "shared info error"},
75+
+ {ERR_PACK(ERR_LIB_DH, 0, DH_R_UNABLE_TO_CHECK_GENERATOR),
76+
+ "unable to check generator"},
77+
+--- a/crypto/dh/dh_key.c
78+
++++ b/crypto/dh/dh_key.c
79+
+@@ -87,6 +87,12 @@ static int generate_key(DH *dh)
80+
+ return 0;
81+
+ }
82+
+
83+
++ if (dh->q != NULL
84+
++ && BN_num_bits(dh->q) > OPENSSL_DH_MAX_MODULUS_BITS) {
85+
++ DHerr(DH_F_GENERATE_KEY, DH_R_Q_TOO_LARGE);
86+
++ return 0;
87+
++ }
88+
++
89+
+ ctx = BN_CTX_new();
90+
+ if (ctx == NULL)
91+
+ goto err;
92+
+@@ -180,6 +186,12 @@ static int compute_key(unsigned char *ke
93+
+ goto err;
94+
+ }
95+
+
96+
++ if (dh->q != NULL
97+
++ && BN_num_bits(dh->q) > OPENSSL_DH_MAX_MODULUS_BITS) {
98+
++ DHerr(DH_F_COMPUTE_KEY, DH_R_Q_TOO_LARGE);
99+
++ goto err;
100+
++ }
101+
++
102+
+ ctx = BN_CTX_new();
103+
+ if (ctx == NULL)
104+
+ goto err;
105+
+--- a/crypto/err/openssl.txt
106+
++++ b/crypto/err/openssl.txt
107+
+@@ -2110,6 +2110,7 @@ DH_R_NO_PARAMETERS_SET:107:no parameters
108+
+ DH_R_NO_PRIVATE_VALUE:100:no private value
109+
+ DH_R_PARAMETER_ENCODING_ERROR:105:parameter encoding error
110+
+ DH_R_PEER_KEY_ERROR:111:peer key error
111+
++DH_R_Q_TOO_LARGE:130:q too large
112+
+ DH_R_SHARED_INFO_ERROR:113:shared info error
113+
+ DH_R_UNABLE_TO_CHECK_GENERATOR:121:unable to check generator
114+
+ DSA_R_BAD_Q_VALUE:102:bad q value
115+
+--- a/include/openssl/dh.h
116+
++++ b/include/openssl/dh.h
117+
+@@ -71,14 +71,16 @@ DECLARE_ASN1_ITEM(DHparams)
118+
+ /* #define DH_GENERATOR_3 3 */
119+
+ # define DH_GENERATOR_5 5
120+
+
121+
+-/* DH_check error codes */
122+
++/* DH_check error codes, some of them shared with DH_check_pub_key */
123+
+ # define DH_CHECK_P_NOT_PRIME 0x01
124+
+ # define DH_CHECK_P_NOT_SAFE_PRIME 0x02
125+
+ # define DH_UNABLE_TO_CHECK_GENERATOR 0x04
126+
+ # define DH_NOT_SUITABLE_GENERATOR 0x08
127+
+ # define DH_CHECK_Q_NOT_PRIME 0x10
128+
+-# define DH_CHECK_INVALID_Q_VALUE 0x20
129+
++# define DH_CHECK_INVALID_Q_VALUE 0x20 /* +DH_check_pub_key */
130+
+ # define DH_CHECK_INVALID_J_VALUE 0x40
131+
++# define DH_MODULUS_TOO_SMALL 0x80
132+
++# define DH_MODULUS_TOO_LARGE 0x100 /* +DH_check_pub_key */
133+
+
134+
+ /* DH_check_pub_key error codes */
135+
+ # define DH_CHECK_PUBKEY_TOO_SMALL 0x01
136+
+--- a/include/openssl/dherr.h
137+
++++ b/include/openssl/dherr.h
138+
+@@ -82,6 +82,7 @@ int ERR_load_DH_strings(void);
139+
+ # define DH_R_NO_PRIVATE_VALUE 100
140+
+ # define DH_R_PARAMETER_ENCODING_ERROR 105
141+
+ # define DH_R_PEER_KEY_ERROR 111
142+
++# define DH_R_Q_TOO_LARGE 130
143+
+ # define DH_R_SHARED_INFO_ERROR 113
144+
+ # define DH_R_UNABLE_TO_CHECK_GENERATOR 121
145+
+

0 commit comments

Comments
 (0)