Skip to content

Commit 0327e17

Browse files
committed
[PA-6132] : Applied CVE Patches to openssl-1.1.1k-7, following patches were applied
1. CVE-2023-3446 2. CVE-2023-5678 3. CVE-2024-0727
1 parent c59ee5a commit 0327e17

File tree

5 files changed

+339
-9
lines changed

5 files changed

+339
-9
lines changed

configs/components/openssl-1.1.1-fips.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
pkg.add_source 'file://resources/patches/openssl/openssl-1.1.1k-7-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'
30+
2731

2832
if platform.name =~ /-7-/
2933
pkg.add_source 'file://resources/patches/openssl/openssl-1.1.1-fips-post-rand.patch'
@@ -55,7 +59,10 @@
5559
"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 -",
5660
"cd openssl-#{pkg.get_version} && /usr/bin/patch --strip=1 --fuzz=0 --ignore-whitespace --no-backup-if-mismatch < ../openssl-1.1.1k-7-fips-spec-file.patch && cd -",
5761
"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 -"
62+
"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 -",
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-3446-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-2023-5678-fips.patch && cd -",
65+
"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 -"
5966
]
6067
end
6168

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
11
--- a/SPECS/openssl.spec 2024-02-20 10:19:41
2-
+++ b/SPECS/openssl.spec 2024-02-23 11:38:58
3-
@@ -87,6 +87,10 @@
2+
+++ b/SPECS/openssl.spec 2024-02-22 20:31:28
3+
@@ -87,6 +87,13 @@
44
Patch84: openssl-1.1.1-cve-2022-1292.patch
55
Patch85: openssl-1.1.1-cve-2022-2068.patch
66
Patch86: openssl-1.1.1-cve-2022-2097.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/
14-
@@ -212,6 +216,10 @@
17+
@@ -212,6 +219,13 @@
1518
%patch84 -p1 -b .cve-2022-1292
1619
%patch85 -p1 -b .cve-2022-2068
1720
%patch86 -p1 -b .cve-2022-2097
1821
+%patch100 -p1 -b .force-fips-on-init
1922
+%patch101 -p1 -b .openssl-cnf-fips-mode
2023
+%patch102 -p1 -b .remove-env-check
2124
+%patch103 -p1 -b .sm2-plaintext
25+
+%patch104 -p1 -F2 -b .CVE-2023-3446-fips
26+
+%patch105 -p1 -F2 -b .CVE-2023-5678-fips
27+
+%patch106 -p1 -b .CVE-2024-0727-fips
2228

2329
%build
2430
# Figure out which flags we want to use.
25-
@@ -220,7 +228,7 @@
31+
@@ -220,7 +234,7 @@
2632
%ifarch %ix86
2733
sslarch=linux-elf
2834
if ! echo %{_target} | grep -q i686 ; then
@@ -31,7 +37,7 @@
3137
fi
3238
%endif
3339
%ifarch x86_64
34-
@@ -286,13 +294,13 @@
40+
@@ -286,13 +300,13 @@
3541
# usable on all platforms. The Configure script already knows to use -fPIC and
3642
# RPM_OPT_FLAGS, so we can skip specifiying them here.
3743
./Configure \
@@ -52,7 +58,7 @@
5258

5359
# Do not run this in a production package the FIPS symbols must be patched-in
5460
#util/mkdef.pl crypto update
55-
@@ -352,9 +360,9 @@
61+
@@ -352,9 +366,9 @@
5662
make DESTDIR=$RPM_BUILD_ROOT install
5763
rename so.%{soversion} so.%{version} $RPM_BUILD_ROOT%{_libdir}/*.so.%{soversion}
5864
for lib in $RPM_BUILD_ROOT%{_libdir}/*.so.%{version} ; do
@@ -65,7 +71,7 @@
6571
done
6672

6773
# Install a makefile for generating keys and self-signed certs, and a script
68-
@@ -375,21 +383,21 @@
74+
@@ -375,21 +389,21 @@
6975
pushd $RPM_BUILD_ROOT%{_mandir}
7076
ln -s -f config.5 man5/openssl.cnf.5
7177
for manpage in man*/* ; do
@@ -99,7 +105,7 @@
99105
done
100106
popd
101107

102-
@@ -424,11 +432,11 @@
108+
@@ -424,11 +438,11 @@
103109
# can have both a 32- and 64-bit version of the library, and they each need
104110
# their own correct-but-different versions of opensslconf.h to be usable.
105111
install -m644 %{SOURCE10} \
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
--- /dev/null 2024-02-21 18:23:03
2+
+++ openssl-1.1.1k/SOURCES/openssl-1.1.1k-CVE-2023-5678-fips.patch 2024-02-14 12:51:49
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)