-
Notifications
You must be signed in to change notification settings - Fork 199
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
Fix CVE-2024-9143 for 8.3-stable #697
Merged
InfoHunter
merged 6 commits into
Tongsuo-Project:8.3-stable
from
dongbeiouba:fix83/CVE-2024-9143
Feb 27, 2025
Merged
Fix CVE-2024-9143 for 8.3-stable #697
InfoHunter
merged 6 commits into
Tongsuo-Project:8.3-stable
from
dongbeiouba:fix83/CVE-2024-9143
Feb 27, 2025
Conversation
This file contains 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
The BN_GF2m_poly2arr() function converts characteristic-2 field (GF_{2^m}) Galois polynomials from a representation as a BIGNUM bitmask, to a compact array with just the exponents of the non-zero terms. These polynomials are then used in BN_GF2m_mod_arr() to perform modular reduction. A precondition of calling BN_GF2m_mod_arr() is that the polynomial must have a non-zero constant term (i.e. the array has `0` as its final element). Internally, callers of BN_GF2m_poly2arr() did not verify that precondition, and binary EC curve parameters with an invalid polynomial could lead to out of bounds memory reads and writes in BN_GF2m_mod_arr(). The precondition is always true for polynomials that arise from the standard form of EC parameters for characteristic-two fields (X9.62). See the "Finite Field Identification" section of: https://www.itu.int/ITU-T/formal-language/itu-t/x/x894/2018-cor1/ANSI-X9-62.html The OpenSSL GF(2^m) code supports only the trinomial and pentanomial basis X9.62 forms. This commit updates BN_GF2m_poly2arr() to return `0` (failure) when the constant term is zero (i.e. the input bitmask BIGNUM is not odd). Additionally, the return value is made unambiguous when there is not enough space to also pad the array with a final `-1` sentinel value. The return value is now always the number of elements (including the final `-1`) that would be filled when the output array is sufficiently large. Previously the same count was returned both when the array has just enough room for the final `-1` and when it had only enough space for non-sentinel values. Finally, BN_GF2m_poly2arr() is updated to reject polynomials whose degree exceeds `OPENSSL_ECC_MAX_FIELD_BITS`, this guards against CPU exhausition attacks via excessively large inputs. The above issues do not arise in processing X.509 certificates. These generally have EC keys from "named curves", and RFC5840 (Section 2.1.1) disallows explicit EC parameters. The TLS code in OpenSSL enforces this constraint only after the certificate is decoded, but, even if explicit parameters are specified, they are in X9.62 form, which cannot represent problem values as noted above. Initially reported as oss-fuzz issue 71623. A closely related issue was earlier reported in <openssl/openssl#19826>. Severity: Low, CVE-2024-9143 (cherry picked from commit 8e008cb8b23ec7dc75c45a66eeed09c815b11cd2)
Fix compilation failure with no-ec.
e39abc8
to
d9e5414
Compare
Also move -Wno-tautological-constant-out-of-range-compare to clang-specific options as it is not supported by gcc. (cherry picked from commit b5863e9259e3c610304febe8b43ac3b1e3b22534)
These warnings trigger on false positives on these platforms with recent compiler update.
d4bef3f
to
ca1e14c
Compare
Gcc 12 has false positives for use-after-free.
6eff554
to
b5c8883
Compare
InfoHunter
approved these changes
Feb 27, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Harden BN_GF2m_poly2arr against misuse.
Add a CHANGES entry for CVE-2024-9143.
Refer https://openssl-library.org/news/secadv/20241016.txt.
Checklist