# CVE-2024-0397: Memory race condition in ssl.SSLContext certificate store methods

> A race condition in Python's ssl module can cause crashes when certificate store methods are called concurrently with certificate loading.

- **Severity:** High 7.4 (`CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 17 Jun 2024
- **Updated:** 3 Nov 2025
- **Also known as:** AZL-42784, AZL-42796, BIT-libpython-2024-0397, BIT-python-2024-0397, BIT-python-min-2024-0397, CLSA-2025-1751144408, CLSA-2025-1751145522, DEBIAN-CVE-2024-0397, GHSA-xhf3-pp4q-gxh5, PSF-2024-4, UBUNTU-CVE-2024-0397, openSUSE-SU-2024:14063-1, openSUSE-SU-2024:14064-1, openSUSE-SU-2024:14066-1

## What is CVE-2024-0397?

CVE-2024-0397 is a high-severity vulnerability in CPython, published on 17 Jun 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

A defect was discovered in the Python “ssl” module where there is a memory
race condition with the ssl.SSLContext methods “cert_store_stats()” and
“get_ca_certs()”. The race condition can be triggered if the methods are
called at the same time as certificates are loaded into the SSLContext,
such as during the TLS handshake with a certificate directory configured.
This issue is fixed in CPython 3.10.14, 3.11.9, 3.12.3, and 3.13.0a5.

Weakness: CWE-362 (Concurrent Execution using Shared Resource with Improper Synchronization)

## Which versions are affected by CVE-2024-0397?

3 open source packages ship an affected version, including libpython, python and python-min.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `libpython` | Bitnami | All versions | 3.8.20, 3.9.20, 3.10.14, 3.11.9, 3.12.3 |
| `python` | Bitnami | All versions | 3.8.20, 3.9.20, 3.10.14, 3.11.9, 3.12.3 |
| `python-min` | Bitnami | All versions | 3.8.20, 3.9.20, 3.10.14, 3.11.9, 3.12.3 |
| `python310` | openSUSE:Tumbleweed | All versions | 3.10.14-2.1 |
| `python38` | openSUSE:Tumbleweed | All versions | 3.8.19-3.1 |
| `python39` | openSUSE:Tumbleweed | All versions | 3.9.19-2.1 |

## How do I fix CVE-2024-0397?

Upgrade libpython to a fixed version for your release line: 3.8.20, 3.9.20, 3.10.14 or 3.11.9.

## Is CVE-2024-0397 being exploited?

There is no known exploitation of CVE-2024-0397 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-0397 and fix it if it is affected.

What it is: CVE-2024-0397 is a high-severity vulnerability in CPython, published on 17 Jun 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2024-0397 in the wild and no public exploit code.

Affected packages and fixed versions:
- libpython (Bitnami): affected all versions; fixed in 3.8.20, 3.9.20, 3.10.14, 3.11.9, 3.12.3
- python (Bitnami): affected all versions; fixed in 3.8.20, 3.9.20, 3.10.14, 3.11.9, 3.12.3
- python-min (Bitnami): affected all versions; fixed in 3.8.20, 3.9.20, 3.10.14, 3.11.9, 3.12.3

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-2024-0397/ (Markdown: https://insights.sbomify.com/CVE-2024-0397/index.md)
```

## Sources

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

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