VAITP Dataset

← Back to the dataset

CVE-2019-19450

Remote code execution in ReportLab (before version 3.5.31) via malicious XML input in Paraparser

  • CVSS 9.8
  • CWE-91 XML Injection (aka Blind XPath Injection)
  • Input Validation and Sanitization
  • Remote

paraparser in ReportLab before 3.5.31 allows remote code execution because start_unichar in paraparser.py evaluates untrusted user input in a unichar element in a crafted XML document with '<unichar code="' followed by arbitrary Python code, a similar issue to CVE-2019-17626.

CVSS base score
9.8
Published
2023-09-20
OWASP
A03 Injection
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
ReportLab
Fixed by upgrading
Yes

Solution

Update ReportLab to version 3.5.31 or higher.

Vulnerable code sample

# Vulnerable code representation for CVE-2019-19450
def start_unichar(attrs):
    code = attrs['code']
    exec(f"unichr({code})")  # Vulnerable to

Patched code sample

Here is an example of how the vulnerability CVE-2019-19450 could be represented in Python code, and how it could be fixed:
```
# Vulnerable code (before ReportLab 3.5.31)
def start_unichar(self, attrs):
    code = attrs['code']
    exec(f"unichr(int({code}))")  # vulnerable to RCE

# Fixed code (ReportLab 3.5.31 and later)
def start_unichar(self, attrs):
    code = attrs['code']
    try:
        code_point = int(code)
        if code_point < 0 or code_point > 0x10ffff:
            raise ValueError("Invalid Unicode code point")
        unichr(code_point)  # safe execution
    except ValueError as e:
        raise ValueError(f"Invalid Unicode code point: {e}")
```
Note that the fixed code uses a `try`-`except` block to validate the input `code` attribute and ensure it is a valid Unicode code point, and then uses the `unichr` function to safely execute the code. The vulnerable code, on the other hand, uses `exec` to execute arbitrary Python code, which allows for remote code execution.

Cite this entry

@misc{vaitp:cve201919450,
  title        = {{Remote code execution in ReportLab (before version 3.5.31) via malicious XML input in Paraparser}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2023},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2019-19450},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2019-19450/}}
}

Download this entry as JSON Download the whole dataset

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 ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.