CVE-2008-2316
Integer overflow in hashlib module
- CVSS 7.5
- CWE-189: Numeric Errors
- Numeric Errors
- Local
Integer overflow in _hashopenssl.c in the hashlib module in Python 2.5.2 and earlier might allow context-dependent attackers to defeat cryptographic digests, related to "partial hashlib hashing of data exceeding 4GB."
- CVSS base score
- 7.5
- Published
- 2008-08-01
- OWASP
- A08 Software and Data Integrity Failures
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Numeric Errors
- Subcategory
- Integer Overflows
- Accessibility scope
- Local
- Impact
- Denial of Service (DoS)
- Fixed by upgrading
- Yes
Solution
Upgrade to Python 2.5.3 or higher.
Vulnerable code sample
import hashlib
class Hash:
def __init__(self):
self.hasher = hashlib.sha256()
self.total_length = 0
def update(self, data):
self.hasher.update(data)
self.total_length += len(data)
def digest(self):
return self.hasher.digest()
hash = Hash()
hash.update(b"A" * (2**31))
print(hash.digest())Patched code sample
import hashlib
class Hash:
def __init__(self):
self.hasher = hashlib.sha256()
self.total_length = 0
def update(self, data):
data_length = len(data)
if self.total_length + data_length > 2**63 - 1:
raise ValueError("Data length exceeds the maximum allowed limit.")
self.hasher.update(data)
self.total_length += data_length
def digest(self):
return self.hasher.digest()
hash = Hash()
hash.update(b"some data")
print(hash.digest())Cite this entry
@misc{vaitp:cve20082316,
title = {{Integer overflow in hashlib module}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2008},
note = {VAITP Python Vulnerability Dataset, entry CVE-2008-2316},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2008-2316/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
