CVE-2022-36040
Rizin 0.4.0 and prior, UNIX-like, PYC file, out-of-bounds write
- CVSS 7.8
- CWE-787 Out-of-bounds Write
- Memory Corruption
- Local
Rizin is a UNIX-like reverse engineering framework and command-line toolset. Versions 0.4.0 and prior are vulnerable to an out-of-bounds write when getting data from PYC(python) files. A user opening a malicious PYC file could be affected by this vulnerability, allowing an attacker to execute code on the user's machine. Commit number 68948017423a12786704e54227b8b2f918c2fd27 contains a patch.
- CVSS base score
- 7.8
- Published
- 2022-09-06
- OWASP
- A08 Software and Data Integrity Failures
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Memory Corruption
- Subcategory
- Out-of-Bound Accesses
- Accessibility scope
- Local
- Impact
- Arbitrary Code Execution
- Fixed by upgrading
- Yes
Solution
Update to Rizin version 0.4.1 or higher.
Vulnerable code sample
def read_pyc(file_path):
with open(file_path, 'rb') as f:
magic = f.read(4)
timestamp = f.read(4)
code_length = f.read(4)
code_length = int.from_bytes(code_length, byteorder='little')
code_data = f.read(code_length)
process_code_object(code_data)
def process_code_object(code_data):
passPatched code sample
def read_pyc(file_path):
try:
with open(file_path, 'rb') as f:
magic = f.read(4)
timestamp = f.read(4)
code_length_bytes = f.read(4)
if len(code_length_bytes) < 4:
raise ValueError("Invalid PYC file: insufficient data")
code_length = int.from_bytes(code_length_bytes, byteorder='little')
code_data = f.read(code_length)
if len(code_data) < code_length:
raise ValueError("Invalid PYC file: code object is truncated")
process_code_object(code_data)
except Exception as e:
print(f"Error reading PYC file: {e}")
def process_code_object(code_data):
passCite this entry
@misc{vaitp:cve202236040,
title = {{Rizin 0.4.0 and prior, UNIX-like, PYC file, out-of-bounds write}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2022},
note = {VAITP Python Vulnerability Dataset, entry CVE-2022-36040},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2022-36040/}}
}
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 ::
