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

High 8.7 Published Updated

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.

Weakness: CWE-770, CWE-400

Which versions are affected by CVE-2024-12254?

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

PackageAffectedFixed in
libpython BitnamiFrom 3.12.03.12.9, 3.13.2
python BitnamiFrom 3.12.03.12.9, 3.13.2
python-min BitnamiFrom 3.12.03.12.9, 3.13.2
Linux distribution packages (8)
python312 SUSE:Linux Enterprise Module for Python 3 15 SP6All versions3.12.8-150600.3.12.1
python312-core SUSE:Linux Enterprise Module for Python 3 15 SP6All versions3.12.8-150600.3.12.1
python312 openSUSE:Leap 15.6All versions3.12.8-150600.3.12.1
python312-core openSUSE:Leap 15.6All versions3.12.8-150600.3.12.1
python312-documentation openSUSE:Leap 15.6All versions3.12.8-150600.3.12.1
python-aiohttp openSUSE:TumbleweedAll versions3.11.16-1.1
python312 openSUSE:TumbleweedAll versions3.12.8-1.1
python313 openSUSE:TumbleweedAll versions3.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.

Is CVE-2024-12254 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free