GHSA-v5w6-wcm8-jm4q CVE-2022-4450 RUSTSEC-2023-0010
openssl-src contains Double free after calling `PEM_read_bio_ex`
- Severity
- 7.5 / 10
- High · CVSS 3.1
- Exploit chance (EPSS)
- 28.59%
- Chance of exploitation in the next 30 days. Higher than 98.13% of scored vulnerabilities.
- Known exploited
- No
- Not in CISA's catalog
- Weakness
- CWE-415 Double Free
- Fix
111.25.0- Upgrade openssl-src to this version or later
Description
The function PEM_read_bio_ex() reads a PEM file from a BIO and parses and decodes the "name" (e.g. "CERTIFICATE"), any header data and the payload data. If the function succeeds then the "name_out", "header" and "data" arguments are populated with pointers to buffers containing the relevant decoded data. The caller is responsible for freeing those buffers. It is possible to construct a PEM file that results in 0 bytes of payload data. In this case PEM_read_bio_ex() will return a failure code but will populate the header argument with a pointer to a buffer that has already been freed. If the caller also frees this buffer then a double free will occur. This will most likely lead to a crash. This could be exploited by an attacker who has the ability to supply malicious PEM files for parsing to achieve a denial of service attack.
The functions PEM_read_bio() and PEM_read() are simple wrappers around PEM_read_bio_ex() and therefore these functions are also directly affected.
These functions are also called indirectly by a number of other OpenSSL functions including PEM_X509_INFO_read_bio_ex() and
SSL_CTX_use_serverinfo_file() which are also vulnerable. Some OpenSSL internal uses of these functions are not vulnerable because the caller does not free the header argument if PEM_read_bio_ex() returns a failure code. These locations include the PEM_read_bio_TYPE() functions as well as the decoders introduced in OpenSSL 3.0.
Affected versions
crates.io
| Package | Vulnerable | Fixed in |
|---|---|---|
| openssl-src | < 111.25.0 |
111.25.0 |
| openssl-src | >= 300.0.0, < 300.0.12 |
300.0.12 |
| openssl-src | >= 0.0.0-0, < 111.25.0>= 300.0.0, < 300.0.12 |
111.25.0300.0.12 |
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 → 111.25.0
- cargo
cargo update -p openssl-src --precise 111.25.0
Severity breakdown
CVSS 3.1 7.5
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
- Attack vector
- Network
- Attack complexity
- Low
- Privileges required
- None
- User interaction
- None
- Scope
- Unchanged
- Confidentiality
- None
- Integrity
- None
- Availability
- High
Weakness
CWE-415: Double Free
The product calls free() twice on the same memory address.
How to prevent it
- Architecture and Design: Choose a language that provides automatic memory management.
- Implementation: Ensure that each allocation is freed only once. After freeing a chunk, set the pointer to NULL to ensure the pointer cannot be freed again. In complicated error conditions, be sure that clean-up routines respect the state of allocation properly. If the language is object oriented, ensure that object destructors delete each chunk of memory only once.
- Implementation: Use a static analysis tool to find double free instances.
References
Advisories
Packages
Other links
- git.openssl.org/gitweb
- git.openssl.org/gitweb
- psirt.global.sonicwall.com/vuln-detail/SNWLID-2023-0003
- rustsec.org/advisories/RUSTSEC-2023-0010.html
- security.gentoo.org/glsa/202402-08
- openssl.org/news/secadv/20230207.txt
- cert-portal.siemens.com/productcert/html/ssa-203374.html
- cert-portal.siemens.com/productcert/html/ssa-337522.html
- cert-portal.siemens.com/productcert/html/ssa-398330.html
- cert-portal.siemens.com/productcert/html/ssa-556635.html
- cert-portal.siemens.com/productcert/html/ssa-561322.html
- cert-portal.siemens.com/productcert/html/ssa-625862.html
- cert-portal.siemens.com/productcert/html/ssa-699386.html
- cert-portal.siemens.com/productcert/html/ssa-769027.html
- cert-portal.siemens.com/productcert/html/ssa-794697.html
- cert-portal.siemens.com/productcert/html/ssa-879734.html
- cert-portal.siemens.com/productcert/html/ssa-943925.html
Timeline
- Published
- Last updated by the source
- Latest EPSS score
Related advisories
| Advisory | Severity | Why 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-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 |
| GHSA-vr8j-hgmm-jh9r Denial of service by double-checked locking in openssl-src | High | Also affects openssl-src |
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