# CVE-2023-38325: cryptography mishandles SSH certificates

> The Python cryptography library mishandles SSH certificates with critical options, allowing attackers to bypass security checks.

- **Severity:** High 7.5 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 14 Jul 2023
- **Updated:** 30 Oct 2024
- **Also known as:** ALPINE-CVE-2023-38325, GHSA-cf7p-gm2m-833m, PYSEC-2023-112, openSUSE-SU-2024:13078-1

## What is CVE-2023-38325?

CVE-2023-38325 is a high-severity vulnerability in n/a, published on 14 Jul 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

The cryptography package before 41.0.2 for Python mishandles SSH certificates that have critical options.

Weakness: CWE-295 (Improper Certificate Validation)

## Which versions are affected by CVE-2023-38325?

3 open source packages ship an affected version, including cryptography. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `cryptography` | PyPI | From 40.0.0 | 41.0.2 |
| `cryptography` | PyPI | From 40.0.0 | 41.0.2 |
| `cryptography` | PyPI | From 40.0.0 | 41.0.2 |
| `python-cryptography` | openSUSE:Tumbleweed | All versions | 41.0.2-2.1 |

Products: Cryptography.io Cryptography.

## How do I fix CVE-2023-38325?

Upgrade cryptography to 41.0.2 or later.

## Is CVE-2023-38325 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-38325 exists.

## Other vulnerabilities in n/a

- [CVE-2020-36242](https://insights.sbomify.com/CVE-2020-36242/): PyCA Cryptography symmetrically encrypting large values can lead to integer overflow (critical 9.1)
- [CVE-2026-26007](https://insights.sbomify.com/CVE-2026-26007/): cryptography Subgroup Attack Due to Missing Subgroup Validation for SECT Curves (high 8.2)
- [CVE-2024-26130](https://insights.sbomify.com/CVE-2024-26130/): cryptography NULL pointer dereference with pkcs12.serialize_key_and_certificates when called with a non-matching certificate and private key and an hmac_hash override (high 7.5)
- [CVE-2026-39892](https://insights.sbomify.com/CVE-2026-39892/): cryptography has a buffer overflow if non-contiguous buffers were passed to APIs (medium 6.9)
- [CVE-2023-49083](https://insights.sbomify.com/CVE-2023-49083/): cryptography vulnerable to NULL-dereference when loading PKCS7 certificates (medium 5.9)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2023-38325 and fix it if it is affected.

What it is: CVE-2023-38325 is a high-severity vulnerability in n/a, published on 14 Jul 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-38325 exists.

Affected packages and fixed versions:
- cryptography (PyPI): affected from 40.0.0; fixed in 41.0.2
- cryptography (PyPI): affected from 40.0.0; fixed in 41.0.2
- cryptography (PyPI): affected from 40.0.0; fixed in 41.0.2

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2023-38325/ (Markdown: https://insights.sbomify.com/CVE-2023-38325/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2023-38325
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2023-38325
- OSV: https://osv.dev/vulnerability/CVE-2023-38325

---
From sbomify Insights: https://insights.sbomify.com/CVE-2023-38325/
Summaries are generated and may contain mistakes; the official description above is the record.
