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.
- Exploited in the wild
- Not known
- Login needed
- Not needed
- Attackable
- Over the internet
- Victim action needed
- Not needed
- Fix
- Available
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.
Which versions are affected by CVE-2024-12254?
3 open source packages ship an affected version, including libpython, python and python-min.
| Package | 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 |
Linux distribution packages (8)
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.
Upgrade, then put limits on request size, rate and nesting depth so one client cannot exhaust the service. More about Denial of service.
Is CVE-2024-12254 being exploited?
There is no known exploitation of CVE-2024-12254 in the wild and no public exploit code.
Sources
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 and 12 more.