# CVE-2024-12254: Unbounded memory buffering in SelectorSocketTransport.writelines()

> Attackers can cause memory exhaustion and denial of service in Python applications using asyncio protocols with writelines() on Linux or macOS.

- **Severity:** High 8.7 (`CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 6 Dec 2024
- **Updated:** 31 Jul 2026
- **Also known as:** ALPINE-CVE-2024-12254, AZL-54042, BELL-CVE-2024-12254, BIT-libpython-2024-12254, BIT-python-2024-12254, BIT-python-min-2024-12254, CLEANSTART-2026-KC88775, DEBIAN-CVE-2024-12254, GHSA-ph84-rcj2-fxxm, MINI-fjr7-w49j-5jpp, MINI-m6h2-g3c7-pwrx, PSF-2024-14, SUSE-SU-2024:4291-1, UBUNTU-CVE-2024-12254, USN-7219-1, openSUSE-SU-2024:14581-1, openSUSE-SU-2025:14691-1, openSUSE-SU-2025:14998-1

## What is CVE-2024-12254?

CVE-2024-12254 is a high-severity denial of service vulnerability in CPython, published on 6 Dec 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

Starting in Python 3.12.0, the asyncio._SelectorSocketTransport.writelines()
 method would not "pause" writing and signal to the Protocol to drain 
the buffer to the wire once the write buffer reached the "high-water 
mark". Because of this, Protocols would not periodically drain the write
 buffer potentially leading to memory exhaustion.

This
 vulnerability likely impacts a small number of users, you must be using
 Python 3.12.0 or later, on macOS or Linux, using the asyncio module 
with protocols, and using .writelines() method which had new 
zero-copy-on-write behavior in Python 3.12.0 and later. If not all of 
these factors are true then your usage of Python is unaffected.

Weakness: CWE-770 (Allocation of Resources Without Limits or Throttling), CWE-400 (Uncontrolled Resource Consumption)

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

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


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `libpython` | Bitnami | From 3.12.0 | 3.12.9, 3.13.2 |
| `python` | Bitnami | From 3.12.0 | 3.12.9, 3.13.2 |
| `python-min` | Bitnami | From 3.12.0 | 3.12.9, 3.13.2 |
| `python312` | SUSE:Linux Enterprise Module for Python 3 15 SP6 | All versions | 3.12.8-150600.3.12.1 |
| `python312-core` | SUSE:Linux Enterprise Module for Python 3 15 SP6 | All versions | 3.12.8-150600.3.12.1 |
| `python312` | openSUSE:Leap 15.6 | All versions | 3.12.8-150600.3.12.1 |
| `python312-core` | openSUSE:Leap 15.6 | All versions | 3.12.8-150600.3.12.1 |
| `python312-documentation` | openSUSE:Leap 15.6 | All versions | 3.12.8-150600.3.12.1 |
| `python-aiohttp` | openSUSE:Tumbleweed | All versions | 3.11.16-1.1 |
| `python312` | openSUSE:Tumbleweed | All versions | 3.12.8-1.1 |
| `python313` | openSUSE:Tumbleweed | All versions | 3.13.1-1.1 |

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

Upgrade libpython to a fixed version for your release line: 3.12.9 or 3.13.2.

## Is CVE-2024-12254 being exploited?

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

## Fix prompt for AI coding agents

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

What it is: CVE-2024-12254 is a high-severity denial of service vulnerability in CPython, published on 6 Dec 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-12254 in the wild and no public exploit code.

Affected packages and fixed versions:
- libpython (Bitnami): affected from 3.12.0; fixed in 3.12.9, 3.13.2
- python (Bitnami): affected from 3.12.0; fixed in 3.12.9, 3.13.2
- python-min (Bitnami): affected from 3.12.0; fixed in 3.12.9, 3.13.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-2024-12254/ (Markdown: https://insights.sbomify.com/CVE-2024-12254/index.md)
```

## Sources

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

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