CVE-2020-5741
Plex Media Server on Windows: Remote code execution via Python deserialization
- CVSS 7.2
- CWE-502 Deserialization of Untrusted Data
- Input Validation and Sanitization
- Remote
Deserialization of Untrusted Data in Plex Media Server on Windows allows a remote, authenticated attacker to execute arbitrary Python code.
- CVSS base score
- 7.2
- Published
- 2020-05-08
- OWASP
- A08 Software and Data Integrity Failures
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Input Validation and Sanitization
- Subcategory
- Insecure Parsing or Deserialization
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Affected component
- Python
- Fixed by upgrading
- Yes
Solution
Update Plex Media Server on Windows to the latest version.
Vulnerable code sample
import pickle
def load_data(serialized_data):
# Vulnerable deserialization of untrusted data
return pickle.loads(serialized_data)
# Example usage
try:
with open("data.pkl", "rb") as f:
data = load_data(f.read())
except Exception as e:
print(f"Error loading data: {e}")Patched code sample
import pickle
import os
def safe_load(serialized_data):
# Use a safer alternative to prevent arbitrary code execution
# Here we use a custom class to restrict what can be deserialized
class SafeLoader(pickle.Unpickler):
def find_class(self, module, name):
# Restrict loading to only specific classes
if module == "trusted_module" and name in ["TrustedClass"]:
return super().find_class(module, name)
raise pickle.UnpicklingError("Unauthorized access to untrusted class")
return SafeLoader(io.BytesIO(serialized_data)).load()
# Example usage
try:
with open("data.pkl", "rb") as f:
data = safe_load(f.read())
except Exception as e:
print(f"Error loading data: {e}")Cite this entry
@misc{vaitp:cve20205741,
title = {{Plex Media Server on Windows: Remote code execution via Python deserialization}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2020},
note = {VAITP Python Vulnerability Dataset, entry CVE-2020-5741},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2020-5741/}}
}
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 ::
