-
Notifications
You must be signed in to change notification settings - Fork 587
[Medium] Patch shim-unsigned-x64 for CVE-2024-9143 #13946
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
v-smalavathu
wants to merge
1
commit into
microsoft:3.0-dev
Choose a base branch
from
v-smalavathu:v-smalavathu/shim-unsigned-x64/CVE-2024-9143_3-shim-unsigned-x64
base: 3.0-dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+90
−3
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
From a69837a1f5b4f192a14cb9fd6e2e67014d9713bc Mon Sep 17 00:00:00 2001 | ||
From: Sreenivasulu Malavathula <v-smalavathu@microsoft.com> | ||
Date: Mon, 2 Jun 2025 18:17:27 -0500 | ||
Subject: [PATCH] Address CVE-2024-9143 | ||
Upstream Patch Reference: https://github.com/openssl/openssl/commit/bc7e04d7c8d509fb78fc0e285aa948fb0da04700 | ||
|
||
--- | ||
Cryptlib/OpenSSL/crypto/bn/bn_gf2m.c | 31 +++++++++++++++++++++------- | ||
1 file changed, 23 insertions(+), 8 deletions(-) | ||
|
||
diff --git a/Cryptlib/OpenSSL/crypto/bn/bn_gf2m.c b/Cryptlib/OpenSSL/crypto/bn/bn_gf2m.c | ||
index 2c61da1..7917365 100644 | ||
--- a/Cryptlib/OpenSSL/crypto/bn/bn_gf2m.c | ||
+++ b/Cryptlib/OpenSSL/crypto/bn/bn_gf2m.c | ||
@@ -95,6 +95,10 @@ | ||
#include "cryptlib.h" | ||
#include "bn_lcl.h" | ||
|
||
+# ifndef OPENSSL_ECC_MAX_FIELD_BITS | ||
+# define OPENSSL_ECC_MAX_FIELD_BITS 661 | ||
+# endif | ||
+ | ||
#ifndef OPENSSL_NO_EC2M | ||
|
||
/* | ||
@@ -1243,16 +1247,26 @@ int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, | ||
/* | ||
* Convert the bit-string representation of a polynomial ( \sum_{i=0}^n a_i * | ||
* x^i) into an array of integers corresponding to the bits with non-zero | ||
- * coefficient. Array is terminated with -1. Up to max elements of the array | ||
- * will be filled. Return value is total number of array elements that would | ||
- * be filled if array was large enough. | ||
+ * coefficient. The array is intended to be suitable for use with | ||
+ * `BN_GF2m_mod_arr()`, and so the constant term of the polynomial must not be | ||
+ * zero. This translates to a requirement that the input BIGNUM `a` is odd. | ||
+ * | ||
+ * Given sufficient room, the array is terminated with -1. Up to max elements | ||
+ * of the array will be filled. | ||
+ * | ||
+ * The return value is total number of array elements that would be filled if | ||
+ * array was large enough, including the terminating `-1`. It is `0` when `a` | ||
+ * is not odd or the constant term is zero contrary to requirement. | ||
+ * | ||
+ * The return value is also `0` when the leading exponent exceeds | ||
+ * `OPENSSL_ECC_MAX_FIELD_BITS`, this guards against CPU exhaustion attacks, | ||
*/ | ||
int BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max) | ||
{ | ||
int i, j, k = 0; | ||
BN_ULONG mask; | ||
|
||
- if (BN_is_zero(a)) | ||
+ if (!BN_is_odd(a)) | ||
return 0; | ||
|
||
for (i = a->top - 1; i >= 0; i--) { | ||
@@ -1270,12 +1284,13 @@ int BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max) | ||
} | ||
} | ||
|
||
- if (k < max) { | ||
+ if (k > 0 && p[0] > OPENSSL_ECC_MAX_FIELD_BITS) | ||
+ return 0; | ||
+ | ||
+ if (k < max) | ||
p[k] = -1; | ||
- k++; | ||
- } | ||
|
||
- return k; | ||
+ return k + 1; | ||
} | ||
|
||
/* | ||
-- | ||
2.45.2 | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/openssl/openssl/blob/master/include/openssl/ec.h#L103