Denial of Service Vulnerability in Python 2.7: Hash Collision Exploit

python2.7 Updated 03 Oct 2025

Summary

19/05/2014
N/A
No i
Unrated
Not published

UBUNTU-CVE-2013-7040: Python 2.7 before 3.4 only uses the last eight bits of the prefix to randomize hash values, which causes it to compute hash values without restricting the ability to trigger hash collisions predictably and makes it easie... Affects python2.7 versions 2.7.5-8ubuntu3 – 2.7.6-8ubuntu0.6+esm9. No fix is published. 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 2.7 is a widely-used programming language known for its simplicity and versatility. It is utilized in various applications ranging from web development to data analysis. However, a vulnerability exists in its hash table implementation, which can lead to denial of service attacks when exploited. This issue arises from the way Python 2.7 handles hash values, specifically using only the last eight bits of the prefix for randomization, making it susceptible to hash collisions.

Vulnerability Detail

Python 2.7 before version 3.4 has a vulnerability that allows attackers to trigger hash collisions predictably. This occurs due to an incomplete fix for CVE-2012-1150, where the hash values are computed without sufficient randomness. As a result, attackers can craft specific inputs that lead to excessive CPU consumption, causing denial of service in applications that rely on hash tables. This vulnerability poses a significant risk, especially in context-dependent scenarios where an attacker can control the input.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →

Workaround

As a temporary workaround, avoid using hash tables with untrusted input or implement input validation to mitigate the risk of hash collision attacks. Additionally, consider using alternative data structures that are less susceptible to such vulnerabilities.

Conclusion

The vulnerability in Python 2.7, identified as CVE-2013-7040, poses a significant risk of denial of service due to predictable hash collisions. It is crucial for users to upgrade to a patched version of Python or implement workarounds to mitigate this risk. Regular monitoring and vulnerability assessment using tools like Vulert can help maintain application security.

See every vulnerability recorded for python2.7 →

Share this vulnerability

FAQ

CVE-2013-7040 is a vulnerability in Python 2.7 that allows attackers to exploit hash collisions, leading to potential denial of service.

You can check if your application is affected by using Vulert, which monitors open-source vulnerabilities in real-time. Visit Vulert Scanner to analyze your manifest file.

The primary risk is denial of service, where an attacker can cause excessive CPU usage by exploiting hash collisions, potentially leading to application downtime.

Yes, the recommended fix is to upgrade to Python 3.4 or later, which includes necessary patches for this vulnerability.

If upgrading is not feasible, implement input validation or avoid using hash tables with untrusted input as a temporary workaround.

Related vulnerabilities

Recent vulnerabilities recorded for python2.7.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. 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