VAITP Dataset

← Back to the dataset

CVE-2019-9189

Arbitrary Python script upload in Prima Systems FlexAir, versions 2.4.9api3 and prior, leads to full system access for authenticated attackers due to root code execution

  • CVSS 8.8
  • CWE-434 Unrestricted Upload of File with Dangerous Type
  • Input Validation and Sanitization
  • Remote

Prima Systems FlexAir, Versions 2.4.9api3 and prior. The application allows the upload of arbitrary Python scripts when configuring the main central controller. These scripts can be immediately executed because of root code execution, not as a web server user, allowing an authenticated attacker to gain full system access.

CVSS base score
8.8
Published
2019-06-05
OWASP
A04 Insecure Design
Orthogonal defect classification
Function
Code defect classification
Incorrect Functionality
Category
Input Validation and Sanitization
Subcategory
Command Injection
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Affected component
Python
Fixed by upgrading
Yes

Solution

Update Prima Systems FlexAir to version 2.4.9api4 or higher.

Vulnerable code sample

def upload_and_execute_script(script_content):
    # Directly execute the uploaded script without validation
    exec(script_content)

# Example usage
user_uploaded_script = """
import os
os.system('whoami')  # This could execute arbitrary commands
"""

upload_and_execute_script(user_uploaded_script)

Patched code sample

import os
import subprocess

def safe_script_upload(script_content):
    # Validate the script content to ensure it doesn't contain malicious code
    if is_safe_script(script_content):
        # Write the script to a temporary file
        with open('/tmp/safe_script.py', 'w') as script_file:
            script_file.write(script_content)
        
        # Execute the script in a safe environment
        subprocess.run(['python3', '/tmp/safe_script.py'], check=True)
    else:
        raise ValueError("Unsafe script content detected.")

def is_safe_script(script_content):
    # Check for disallowed keywords or patterns in the script
    disallowed_keywords = ['import', 'os', 'subprocess', 'eval', 'exec']
    return not any(keyword in script_content for keyword in disallowed_keywords)

# Example usage
try:
    user_script = "print('Hello, world!')"  # This is safe
    safe_script_upload(user_script)
except ValueError as e:
    print(e)

Cite this entry

@misc{vaitp:cve20199189,
  title        = {{Arbitrary Python script upload in Prima Systems FlexAir, versions 2.4.9api3 and prior, leads to full system access for authenticated attackers due to root code execution}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2019},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2019-9189},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2019-9189/}}
}

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.