Use-After-Free Vulnerability in Python 3.9 via heapq's heappushpop

python2.7 Updated 02 Oct 2025

Summary

22/08/2023
N/A
Yes i
High
7.5

CVE-2022-48560: A use-after-free exists in Python through 3.9 via heappushpop in heapq. Affects python2.7 across 2 version ranges.

< 2.7.18-8+deb11u1 < d56cd4006a1c5e07b0bf69fad9fc8e2fbf6aa855

Fixed in 2.7.18-8+deb11u1. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

Python is a widely-used high-level programming language known for its readability and versatility. It supports multiple programming paradigms and is extensively used in web development, data analysis, artificial intelligence, and more. The vulnerability in question affects Python 3.9 through the heapq module's heappushpop function, which can lead to memory management issues.

Vulnerability Detail

A use-after-free vulnerability exists in Python 3.9, specifically in the heapq module's heappushpop function. This flaw arises when the function attempts to access memory that has already been freed, potentially leading to arbitrary code execution or application crashes. The vulnerability can be exploited by attackers to manipulate memory, which may result in data corruption or unauthorized access to sensitive information.

How To Fix

Minimum fixed version

2.7.18-8+deb11u1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade python2.7

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary workaround, avoid using the heappushpop function in the heapq module until the vulnerability is patched. Consider using alternative methods for heap operations that do not involve this function.

Conclusion

The use-after-free vulnerability in Python 3.9's heapq module poses significant risks, including potential memory corruption and unauthorized access. Users are advised to upgrade their Python installations to mitigate these risks and ensure the security of their applications.

See every vulnerability recorded for python2.7 →

Share this vulnerability

FAQ

A use-after-free vulnerability occurs when a program continues to use a memory location after it has been freed, leading to potential memory corruption or exploitation.

You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.

Exploitation of this vulnerability can lead to application crashes, arbitrary code execution, or unauthorized access to sensitive data.

Yes, upgrading to a version of Python that has addressed this vulnerability is essential. Ensure you are using a version later than the fixed releases.

The CVSS score for this vulnerability is 7.5, indicating a high severity level.

Related vulnerabilities

Recent vulnerabilities recorded for python2.7.

How To Fix

Minimum fixed version

2.7.18-8+deb11u1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade python2.7

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback