CVE-2022-42919
Local privilege escalation vulnerability in Python's multiprocessing library on Linux
- CVSS 7.8
- CWE-502
- Input Validation and Sanitization
- Local
Python 3.9.x before 3.9.16 and 3.10.x before 3.10.9 on Linux allows local privilege escalation in a non-default configuration. The Python multiprocessing library, when used with the forkserver start method on Linux, allows pickles to be deserialized from any user in the same machine local network namespace, which in many system configurations means any user on the same machine. Pickles can execute arbitrary code. Thus, this allows for local user privilege escalation to the user that any forkserver process is running as. Setting multiprocessing.util.abstract_sockets_supported to False is a workaround. The forkserver start method for multiprocessing is not the default start method. This issue is Linux specific because only Linux supports abstract namespace sockets. CPython before 3.9 does not make use of Linux abstract namespace sockets by default. Support for users manually specifying an abstract namespace socket was added as a bugfix in 3.7.8 and 3.8.3, but users would need to make specific uncommon API calls in order to do that in CPython before 3.9.
- CWE
- CWE-502
- CVSS base score
- 7.8
- Published
- 2022-11-07
- OWASP
- A08 Software and Data Integrity Failures
- Orthogonal defect classification
- Timing/Serialization
- Code defect classification
- Serialization Issues
- Category
- Input Validation and Sanitization
- Subcategory
- Insecure Parsing or Deserialization
- Accessibility scope
- Local
- Impact
- Privilege Escalation
- Fixed by upgrading
- Yes
Solution
Upgrade to Python 3.9.16 or 3.10.9 and set multiprocessing.util.abstract_sockets_supported to False.
Vulnerable code sample
import multiprocessing
import pickle
def function():
# VULNERABLE: This code is susceptible to deserialization
print("Worker is running")
if __name__ == "__main__":
multiprocessing.set_start_method('forkserver')
data = pickle.dumps(function)
worker = multiprocessing.Process(target=pickle.loads, args=(data,))
worker.start()
worker.join()Patched code sample
import multiprocessing
multiprocessing.util.abstract_sockets_supported = False
def function():
# SECURE: This version prevents deserialization
print("Worker is running")
if __name__ == "__main__":
multiprocessing.set_start_method('forkserver')
worker = multiprocessing.Process(target=function)
worker.start()
worker.join()Cite this entry
@misc{vaitp:cve202242919,
title = {{Local privilege escalation vulnerability in Python's multiprocessing library on Linux}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2022},
note = {VAITP Python Vulnerability Dataset, entry CVE-2022-42919},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2022-42919/}}
}
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 ::
