CVE-2024-21506
Out-of-bounds Read vulnerability in pymongo bson module before 4.6.3.
- CVSS 5.2
- CWE-125
- Memory Corruption
- Remote
Versions of the package pymongo before 4.6.3 are vulnerable to Out-of-bounds Read in the bson module. Using the crafted payload the attacker could force the parser to deserialize unmanaged memory. The parser tries to interpret bytes next to buffer and throws an exception with string. If the following bytes are not printable UTF-8 the parser throws an exception with a single byte.
- CWE
- CWE-125
- CVSS base score
- 5.2
- Published
- 2024-04-06
- OWASP
- A05 Security Misconfiguration
- Orthogonal defect classification
- Algorithm
- Code defect classification
- Incorrect Functionality
- Category
- Memory Corruption
- Subcategory
- Out-of-Bound Accesses
- Accessibility scope
- Remote
- Impact
- Denial of Service (DoS)
- Affected component
- pymongo
- Fixed by upgrading
- Yes
Solution
Upgrade to pymongo version 4.6.3 or later.
Vulnerable code sample
import pymongo
from bson import BSON
data = b'\x16\x00\x00\x00\x02name\x00\x05\x00\x00\x00Alice\x00\x00\xff\xff\xff'
try:
document = BSON(data).decode()
print(document)
except Exception as e:
print(f'Error: {e}')Patched code sample
import pymongo
from bson import BSON
data = b'\x16\x00\x00\x00\x02name\x00\x05\x00\x00\x00Alice\x00\x00\xff\xff\xff'
try:
if data:
document = BSON(data).decode()
print(document)
else:
print("Empty data received")
except Exception as e:
print(f'Error: {e}')Payload
malicious_payload = b'\x16\x00\x00\x00\x02name\x00\x05\x00\x00\x00Alice\x00\x00\xff\xff\xff'
Cite this entry
@misc{vaitp:cve202421506,
title = {{Out-of-bounds Read vulnerability in pymongo bson module before 4.6.3.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2024},
note = {VAITP Python Vulnerability Dataset, entry CVE-2024-21506},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2024-21506/}}
}
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 ::
