VAITP Dataset

← Back to the dataset

CVE-2022-30286

PyScriptJS (PyScript Demonstrator) through 2022-05-04 allows remote Python source code access

  • CVSS 7.5
  • CWE-918: Server-Side Request Forgery (SSRF)
  • Information Leakage
  • Remote

pyscriptjs (aka PyScript Demonstrator) in PyScript through 2022-05-04 allows a remote user to read Python source code.

CVSS base score
7.5
Published
2022-05-09
OWASP
A05 Security Misconfiguration
Orthogonal defect classification
Function
Code defect classification
Incorrect Functionality
Category
Information Leakage
Subcategory
Information Disclosure
Accessibility scope
Remote
Impact
Information Disclosure
Affected component
PyScript
Fixed by upgrading
Yes

Solution

Update PyScript to version 2022-05-05 or higher.

Vulnerable code sample

def read_file(file_path):
    with open(file_path, 'r') as file:
        return file.read()

# Usage
code = read_file("/path/to/python_script.py")
print(code)

Patched code sample

import os

def safe_read_file(file_path):
    # Ensure the file path is within a safe directory
    safe_directory = "/safe/directory/"
    if os.path.commonpath([file_path, safe_directory]) == safe_directory:
        with open(file_path, 'r') as file:
            return file.read()
    else:
        raise ValueError("Access to the specified file is not allowed.")

# Usage
try:
    code = safe_read_file("/safe/directory/example.py")
    print(code)
except ValueError as e:
    print(e)

Cite this entry

@misc{vaitp:cve202230286,
  title        = {{PyScriptJS (PyScript Demonstrator) through 2022-05-04 allows remote Python source code access}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2022},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2022-30286},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2022-30286/}}
}

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.