Skip to content

GHSA-4f63-89w9-3jjv CVE-2022-3358 RUSTSEC-2022-0059

Using a Custom Cipher with `NID_undef` may lead to NULL encryption

High crates.io
Severity
7.5 / 10
High · CVSS 3.1
Exploit chance (EPSS)
4.01%
Chance of exploitation in the next 30 days. Higher than 90.56% of scored vulnerabilities.
Known exploited
No
Not in CISA's catalog
Weakness
CWE-476 NULL Pointer Dereference
Fix
300.0.10
Upgrade openssl-src to this version or later

Description

OpenSSL supports creating a custom cipher via the legacy EVP_CIPHER_meth_new() function and associated function calls. This function was deprecated in OpenSSL 3.0 and application authors are instead encouraged to use the new provider mechanism in order to implement custom ciphers. OpenSSL versions 3.0.0 to 3.0.5 incorrectly handle legacy custom ciphers passed to the EVP_EncryptInit_ex2(), EVP_DecryptInit_ex2() and EVP_CipherInit_ex2() functions (as well as other similarly named encryption and decryption initialisation functions). Instead of using the custom cipher directly it incorrectly tries to fetch an equivalent cipher from the available providers. An equivalent cipher is found based on the NID passed to EVP_CIPHER_meth_new(). This NID is supposed to represent the unique NID for a given cipher. However it is possible for an application to incorrectly pass NID_undef as this value in the call to EVP_CIPHER_meth_new(). When NID_undef is used in this way the OpenSSL encryption/decryption initialisation function will match the NULL cipher as being equivalent and will fetch this from the available providers. This will succeed if the default provider has been loaded (or if a third party provider has been loaded that offers this cipher). Using the NULL cipher means that the plaintext is emitted as the ciphertext. Applications are only affected by this issue if they call EVP_CIPHER_meth_new() using NID_undef and subsequently use it in a call to an encryption/decryption initialisation function. Applications that only use SSL/TLS are not impacted by this issue. Fixed in OpenSSL 3.0.6 (Affected 3.0.0-3.0.5).

Affected versions

crates.io

PackageVulnerableFixed in
openssl-src
>= 300.0.0, < 300.0.10
300.0.10

How to fix

Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.

openssl-src crates.io → 300.0.10

cargo
cargo update -p openssl-src --precise 300.0.10

Severity breakdown

CVSS 3.1 7.5

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
None
Availability
None

Weakness

CWE-476: NULL Pointer Dereference

The product dereferences a pointer that it expects to be valid but is NULL.

How to prevent it
  • Implementation: For any pointers that could have been modified or provided from a function that can return NULL, check the pointer for NULL before use. When working with a multithreaded or otherwise asynchronous environment, ensure that proper locking APIs are used to lock before the check, and unlock when it has finished [REF-1484].
  • Requirements: Select a programming language that is not susceptible to these issues.
  • Implementation: Check the results of all functions that return a value and verify that the value is non-null before acting upon it.
  • Architecture and Design: Identify all variables and data stores that receive information from external sources, and apply input validation to make sure that they are only initialized to expected values.
  • Implementation: Explicitly initialize all variables and other data stores, either during declaration or just before the first usage.

References

Timeline

  1. Published
  2. Last updated by the source
  3. Latest EPSS score
AdvisorySeverityWhy it's related
GHSA-w67w-mw4j-8qrv
openssl-src contains Read Buffer Overflow in X.509 Name Constraint
Medium Also affects openssl-src
GHSA-vrh7-x64v-7vxq
openssl-src contains `NULL` dereference during PKCS7 data verification
High Also affects openssl-src
GHSA-vxrh-cpg7-8vjr
openssl-src subject to NULL dereference validating DSA public key
High Also affects openssl-src
GHSA-r7jw-wp68-3xch
openssl-src vulnerable to Use-after-free following `BIO_new_NDEF`
High Also affects openssl-src
GHSA-v5w6-wcm8-jm4q
openssl-src contains Double free after calling `PEM_read_bio_ex`
High Also affects openssl-src
GHSA-p52g-cm5j-mjv4
openssl-src subject to Timing Oracle in RSA Decryption
Medium Also affects openssl-src
GHSA-29xx-hcv2-c4cp
openssl-src subject to Invalid pointer dereference in `d2i_PKCS7` functions
High Also affects openssl-src
GHSA-x4qr-2fvf-3mr5
Vulnerable OpenSSL included in cryptography wheels
High Also affects openssl-src
Is this in your code?

MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.

Check your repos with MergeHarbor