Skip to content

Commit 3e3afc8

Browse files
authored
[MEDIUM] Patch edk2 for CVE-2024-2511, CVE-2024-38796 & CVE-2024-4603 (#13715)
1 parent 5fa8c7f commit 3e3afc8

5 files changed

Lines changed: 264 additions & 3 deletions

File tree

SPECS-SIGNED/edk2-hvloader-signed/edk2-hvloader-signed.spec

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
Summary: Signed HvLoader.efi for %{buildarch} systems
1212
Name: edk2-hvloader-signed-%{buildarch}
1313
Version: %{GITDATE}git%{GITCOMMIT}
14-
Release: 6%{?dist}
14+
Release: 8%{?dist}
1515
License: MIT
1616
Vendor: Microsoft Corporation
1717
Distribution: Azure Linux
@@ -74,6 +74,12 @@ popd
7474
/boot/efi/HvLoader.efi
7575

7676
%changelog
77+
* Thu Apr 24 2025 Jyoti Kanase <v-jykanase@microsoft.com> - 20240524git3e722403cd16-8
78+
- Bump release for consistency with edk2 spec.
79+
80+
* Wed Apr 23 2025 Archana Choudhary <archana1@microsoft.com> - 20240524git3e722403cd16-7
81+
- Bump release for consistency with edk2 spec.
82+
7783
* Tue Apr 15 2025 Tobias Brick <tobiasb@microsoft.com> - 20240524git3e722403cd16-6
7884
- Bump release for consistency with edk2 spec.
7985

SPECS/edk2/CVE-2024-2511.patch

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
From dfa811c4173d0b520de4cfb0e7794781ad41289a Mon Sep 17 00:00:00 2001
2+
From: Archana Choudhary <archana1@microsoft.com>
3+
Date: Tue, 29 Apr 2025 09:04:40 +0000
4+
Subject: [PATCH] Patch for CVE-2024-2511
5+
6+
Ported from https://github.com/openssl/openssl/commit/b52867a9f618bb955bed2a3ce3db4d4f97ed8e5d
7+
---
8+
.../Library/OpensslLib/openssl/ssl/ssl_lib.c | 5 ++--
9+
.../Library/OpensslLib/openssl/ssl/ssl_sess.c | 28 +++++++++++++++----
10+
.../openssl/ssl/statem/statem_srvr.c | 5 ++--
11+
3 files changed, 27 insertions(+), 11 deletions(-)
12+
13+
diff --git a/CryptoPkg/Library/OpensslLib/openssl/ssl/ssl_lib.c b/CryptoPkg/Library/OpensslLib/openssl/ssl/ssl_lib.c
14+
index 99ce450..158b550 100644
15+
--- a/CryptoPkg/Library/OpensslLib/openssl/ssl/ssl_lib.c
16+
+++ b/CryptoPkg/Library/OpensslLib/openssl/ssl/ssl_lib.c
17+
@@ -3717,9 +3717,10 @@ void ssl_update_cache(SSL *s, int mode)
18+
19+
/*
20+
* If the session_id_length is 0, we are not supposed to cache it, and it
21+
- * would be rather hard to do anyway :-)
22+
+ * would be rather hard to do anyway :-). Also if the session has already
23+
+ * been marked as not_resumable we should not cache it for later reuse.
24+
*/
25+
- if (s->session->session_id_length == 0)
26+
+ if (s->session->session_id_length == 0 || s->session->not_resumable)
27+
return;
28+
29+
/*
30+
diff --git a/CryptoPkg/Library/OpensslLib/openssl/ssl/ssl_sess.c b/CryptoPkg/Library/OpensslLib/openssl/ssl/ssl_sess.c
31+
index 68b57a5..c1c7837 100644
32+
--- a/CryptoPkg/Library/OpensslLib/openssl/ssl/ssl_sess.c
33+
+++ b/CryptoPkg/Library/OpensslLib/openssl/ssl/ssl_sess.c
34+
@@ -152,16 +152,11 @@ SSL_SESSION *SSL_SESSION_new(void)
35+
return ss;
36+
}
37+
38+
-SSL_SESSION *SSL_SESSION_dup(const SSL_SESSION *src)
39+
-{
40+
- return ssl_session_dup(src, 1);
41+
-}
42+
-
43+
/*
44+
* Create a new SSL_SESSION and duplicate the contents of |src| into it. If
45+
* ticket == 0 then no ticket information is duplicated, otherwise it is.
46+
*/
47+
-SSL_SESSION *ssl_session_dup(const SSL_SESSION *src, int ticket)
48+
+static SSL_SESSION *ssl_session_dup_intern(const SSL_SESSION *src, int ticket)
49+
{
50+
SSL_SESSION *dest;
51+
52+
@@ -281,6 +276,27 @@ SSL_SESSION *ssl_session_dup(const SSL_SESSION *src, int ticket)
53+
return NULL;
54+
}
55+
56+
+SSL_SESSION *SSL_SESSION_dup(const SSL_SESSION *src)
57+
+{
58+
+ return ssl_session_dup_intern(src, 1);
59+
+}
60+
+
61+
+/*
62+
+ * Used internally when duplicating a session which might be already shared.
63+
+ * We will have resumed the original session. Subsequently we might have marked
64+
+ * it as non-resumable (e.g. in another thread) - but this copy should be ok to
65+
+ * resume from.
66+
+ */
67+
+SSL_SESSION *ssl_session_dup(const SSL_SESSION *src, int ticket)
68+
+{
69+
+ SSL_SESSION *sess = ssl_session_dup_intern(src, ticket);
70+
+
71+
+ if (sess != NULL)
72+
+ sess->not_resumable = 0;
73+
+
74+
+ return sess;
75+
+}
76+
+
77+
const unsigned char *SSL_SESSION_get_id(const SSL_SESSION *s, unsigned int *len)
78+
{
79+
if (len)
80+
diff --git a/CryptoPkg/Library/OpensslLib/openssl/ssl/statem/statem_srvr.c b/CryptoPkg/Library/OpensslLib/openssl/ssl/statem/statem_srvr.c
81+
index a9e67f9..6c942e6 100644
82+
--- a/CryptoPkg/Library/OpensslLib/openssl/ssl/statem/statem_srvr.c
83+
+++ b/CryptoPkg/Library/OpensslLib/openssl/ssl/statem/statem_srvr.c
84+
@@ -2338,9 +2338,8 @@ int tls_construct_server_hello(SSL *s, WPACKET *pkt)
85+
* so the following won't overwrite an ID that we're supposed
86+
* to send back.
87+
*/
88+
- if (s->session->not_resumable ||
89+
- (!(s->ctx->session_cache_mode & SSL_SESS_CACHE_SERVER)
90+
- && !s->hit))
91+
+ if (!(s->ctx->session_cache_mode & SSL_SESS_CACHE_SERVER)
92+
+ && !s->hit)
93+
s->session->session_id_length = 0;
94+
95+
if (usetls13) {

SPECS/edk2/CVE-2024-38796.patch

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
From a6d8206a22d70dc5e6d7ac8aae8e69b80ace7e61 Mon Sep 17 00:00:00 2001
2+
From: jykanase <v-jykanase@microsoft.com>
3+
Date: Wed, 2 Apr 2025 05:23:55 +0000
4+
Subject: [PATCH] CVE-2024-38796
5+
6+
Upstream patch reference: https://github.com/tianocore/edk2/commit/c95233b8525ca6828921affd1496146cff262e65
7+
---
8+
MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 2 +-
9+
1 file changed, 1 insertion(+), 1 deletion(-)
10+
11+
diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
12+
index 86ff2e7..128090d 100644
13+
--- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
14+
+++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
15+
@@ -1054,7 +1054,7 @@ PeCoffLoaderRelocateImage (
16+
RelocDir = &Hdr.Te->DataDirectory[0];
17+
}
18+
19+
- if ((RelocDir != NULL) && (RelocDir->Size > 0)) {
20+
+ if ((RelocDir != NULL) && (RelocDir->Size > 0) && (RelocDir->Size - 1 < MAX_UINT32 - RelocDir->VirtualAddress)) {
21+
RelocBase = (EFI_IMAGE_BASE_RELOCATION *)PeCoffLoaderImageAddress (ImageContext, RelocDir->VirtualAddress, TeStrippedOffset);
22+
RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *)PeCoffLoaderImageAddress (
23+
ImageContext,
24+
--
25+
2.45.2
26+

SPECS/edk2/CVE-2024-4603.patch

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
From d2bbe37ccf8857197a4b6c36fc0381ab58bb8b09 Mon Sep 17 00:00:00 2001
2+
From: Archana Choudhary <archana1@microsoft.com>
3+
Date: Tue, 29 Apr 2025 09:12:17 +0000
4+
Subject: [PATCH] Fix for CVE-2024-4603
5+
6+
Ported from https://github.com/openssl/openssl/commit/3559e868e58005d15c6013a0c1fd832e51c73397
7+
---
8+
.../Library/OpensslLib/openssl/CHANGES.md | 17 +++++++
9+
.../OpensslLib/openssl/crypto/dsa/dsa_check.c | 45 +++++++++++++++++--
10+
2 files changed, 58 insertions(+), 4 deletions(-)
11+
12+
diff --git a/CryptoPkg/Library/OpensslLib/openssl/CHANGES.md b/CryptoPkg/Library/OpensslLib/openssl/CHANGES.md
13+
index 84933a8..34a2e7f 100644
14+
--- a/CryptoPkg/Library/OpensslLib/openssl/CHANGES.md
15+
+++ b/CryptoPkg/Library/OpensslLib/openssl/CHANGES.md
16+
@@ -30,6 +30,23 @@ breaking changes, and mappings for the large list of deprecated functions.
17+
18+
### Changes between 3.0.6 and 3.0.7 [1 Nov 2022]
19+
20+
+ * Fixed an issue where checking excessively long DSA keys or parameters may
21+
+ be very slow.
22+
+
23+
+ Applications that use the functions EVP_PKEY_param_check() or
24+
+ EVP_PKEY_public_check() to check a DSA public key or DSA parameters may
25+
+ experience long delays. Where the key or parameters that are being checked
26+
+ have been obtained from an untrusted source this may lead to a Denial of
27+
+ Service.
28+
+
29+
+ To resolve this issue DSA keys larger than OPENSSL_DSA_MAX_MODULUS_BITS
30+
+ will now fail the check immediately with a DSA_R_MODULUS_TOO_LARGE error
31+
+ reason.
32+
+
33+
+ ([CVE-2024-4603])
34+
+
35+
+ *Tomáš Mráz*
36+
+
37+
* Fixed two buffer overflows in punycode decoding functions.
38+
39+
A buffer overrun can be triggered in X.509 certificate verification,
40+
diff --git a/CryptoPkg/Library/OpensslLib/openssl/crypto/dsa/dsa_check.c b/CryptoPkg/Library/OpensslLib/openssl/crypto/dsa/dsa_check.c
41+
index 7ee914a..a66fe05 100644
42+
--- a/CryptoPkg/Library/OpensslLib/openssl/crypto/dsa/dsa_check.c
43+
+++ b/CryptoPkg/Library/OpensslLib/openssl/crypto/dsa/dsa_check.c
44+
@@ -19,8 +19,34 @@
45+
#include "dsa_local.h"
46+
#include "crypto/dsa.h"
47+
48+
+static int dsa_precheck_params(const DSA *dsa, int *ret)
49+
+{
50+
+ if (dsa->params.p == NULL || dsa->params.q == NULL) {
51+
+ ERR_raise(ERR_LIB_DSA, DSA_R_BAD_FFC_PARAMETERS);
52+
+ *ret = FFC_CHECK_INVALID_PQ;
53+
+ return 0;
54+
+ }
55+
+
56+
+ if (BN_num_bits(dsa->params.p) > OPENSSL_DSA_MAX_MODULUS_BITS) {
57+
+ ERR_raise(ERR_LIB_DSA, DSA_R_MODULUS_TOO_LARGE);
58+
+ *ret = FFC_CHECK_INVALID_PQ;
59+
+ return 0;
60+
+ }
61+
+
62+
+ if (BN_num_bits(dsa->params.q) >= BN_num_bits(dsa->params.p)) {
63+
+ ERR_raise(ERR_LIB_DSA, DSA_R_BAD_Q_VALUE);
64+
+ *ret = FFC_CHECK_INVALID_PQ;
65+
+ return 0;
66+
+ }
67+
+
68+
+ return 1;
69+
+}
70+
+
71+
int ossl_dsa_check_params(const DSA *dsa, int checktype, int *ret)
72+
{
73+
+ if (!dsa_precheck_params(dsa, ret))
74+
+ return 0;
75+
+
76+
if (checktype == OSSL_KEYMGMT_VALIDATE_QUICK_CHECK)
77+
return ossl_ffc_params_simple_validate(dsa->libctx, &dsa->params,
78+
FFC_PARAM_TYPE_DSA, ret);
79+
@@ -39,6 +65,9 @@ int ossl_dsa_check_params(const DSA *dsa, int checktype, int *ret)
80+
*/
81+
int ossl_dsa_check_pub_key(const DSA *dsa, const BIGNUM *pub_key, int *ret)
82+
{
83+
+ if (!dsa_precheck_params(dsa, ret))
84+
+ return 0;
85+
+
86+
return ossl_ffc_validate_public_key(&dsa->params, pub_key, ret);
87+
}
88+
89+
@@ -49,6 +78,10 @@ int ossl_dsa_check_pub_key(const DSA *dsa, const BIGNUM *pub_key, int *ret)
90+
*/
91+
int ossl_dsa_check_pub_key_partial(const DSA *dsa, const BIGNUM *pub_key, int *ret)
92+
{
93+
+
94+
+ if (!dsa_precheck_params(dsa, ret))
95+
+ return 0;
96+
+
97+
return ossl_ffc_validate_public_key_partial(&dsa->params, pub_key, ret);
98+
}
99+
100+
@@ -56,8 +89,10 @@ int ossl_dsa_check_priv_key(const DSA *dsa, const BIGNUM *priv_key, int *ret)
101+
{
102+
*ret = 0;
103+
104+
- return (dsa->params.q != NULL
105+
- && ossl_ffc_validate_private_key(dsa->params.q, priv_key, ret));
106+
+ if (!dsa_precheck_params(dsa, ret))
107+
+ return 0;
108+
+
109+
+ return ossl_ffc_validate_private_key(dsa->params.q, priv_key, ret);
110+
}
111+
112+
/*
113+
@@ -70,8 +105,10 @@ int ossl_dsa_check_pairwise(const DSA *dsa)
114+
BN_CTX *ctx = NULL;
115+
BIGNUM *pub_key = NULL;
116+
117+
- if (dsa->params.p == NULL
118+
- || dsa->params.g == NULL
119+
+ if (!dsa_precheck_params(dsa, &ret))
120+
+ return 0;
121+
+
122+
+ if (dsa->params.g == NULL
123+
|| dsa->priv_key == NULL
124+
|| dsa->pub_key == NULL)
125+
return 0;

SPECS/edk2/edk2.spec

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ ExclusiveArch: x86_64
5555

5656
Name: edk2
5757
Version: %{GITDATE}git%{GITCOMMIT}
58-
Release: 6%{?dist}
58+
Release: 8%{?dist}
5959
Summary: UEFI firmware for 64-bit virtual machines
6060
License: Apache-2.0 AND (BSD-2-Clause OR GPL-2.0-or-later) AND BSD-2-Clause-Patent AND BSD-3-Clause AND BSD-4-Clause AND ISC AND MIT AND LicenseRef-Fedora-Public-Domain
61-
URL: http://www.tianocore.org
61+
URL: https://www.tianocore.org
6262

6363
# The source tarball is created using following commands:
6464
# COMMIT=bb1bba3d7767
@@ -129,12 +129,15 @@ Patch0017: 0017-silence-.-has-a-LOAD-segment-with-RWX-permissions-wa.patch
129129
%endif
130130
Patch0018: 0018-NetworkPkg-TcpDxe-Fixed-system-stuck-on-PXE-boot-flo.patch
131131
Patch0019: 0019-NetworkPkg-DxeNetLib-adjust-PseudoRandom-error-loggi.patch
132+
Patch0020: CVE-2024-38796.patch
132133

133134
# Patches for the vendored OpenSSL are in the range from 1000 to 1999 (inclusive).
134135
Patch1000: CVE-2022-3996.patch
135136
Patch1001: CVE-2024-6119.patch
136137
Patch1002: CVE-2024-4741.patch
137138
Patch1003: CVE-2024-13176.patch
139+
Patch1004: CVE-2024-2511.patch
140+
Patch1005: CVE-2024-4603.patch
138141

139142
# python3-devel and libuuid-devel are required for building tools.
140143
# python3-devel is also needed for varstore template generation and
@@ -796,6 +799,12 @@ done
796799
/boot/efi/HvLoader.efi
797800

798801
%changelog
802+
* Thu Apr 24 2025 Jyoti Kanase <v-jykanase@microsoft.com> - 20240524git3e722403cd16-8
803+
- Fix CVE-2024-38796
804+
805+
* Wed Apr 23 2025 Archana Choudhary <archana1@microsoft.com> - 20240524git3e722403cd16-7
806+
- Add patch for CVE-2024-2511, CVE-2024-4603
807+
799808
* Mon Apr 14 2025 Tobias Brick <tobiasb@microsoft.com> - 20240524git3e722403cd16-6
800809
- Patch CVE-2024-13176.
801810
- Rename patch for CVE-2024-4741 to standard name format.

0 commit comments

Comments
 (0)