VAITP Dataset

← Back to the dataset

CVE-2023-37941

Apache Superset metadata db write access leads to remote code execution

  • CVSS 6.6
  • CWE-502 Deserialization of Untrusted Data
  • Input Validation and Sanitization
  • Remote

If an attacker gains write access to the Apache Superset metadata database, they could persist a specifically crafted Python object that may lead to remote code execution on Superset's web backend. The Superset metadata db is an 'internal' component that is typically only accessible directly by the system administrator and the superset process itself. Gaining access to that database should be difficult and require significant privileges. This vulnerability impacts Apache Superset versions 1.5.0 up to and including 2.1.0. Users are recommended to upgrade to version 2.1.1 or later.

CVSS base score
6.6
Published
2023-09-06
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
Fixed by upgrading
Yes

Solution

Update Apache Superset to version 2.1.1 or later.

Vulnerable code sample

import pickle
import sqlalchemy

# Assuming `session` is your SQLAlchemy session connected to the Superset metadata database

def persist_vulnerable_object(obj):
    # Serialize the object using pickle (vulnerable to arbitrary code execution)
    data = pickle.dumps(obj)
    
    # Store the serialized data in the database
    new_entry = YourModel(data=data)  # Replace YourModel with your actual model
    session.add(new_entry)
    session.commit()

# Example usage
user_input = {'key': 'value', '__reduce__': (os.system, ('echo Vulnerable!',))}  # Malicious input
persist_vulnerable_object(user_input)

Patched code sample

import pickle
import sqlalchemy

# Assuming `session` is your SQLAlchemy session connected to the Superset metadata database

def safe_load(data):
    # Only allow loading of safe types
    allowed_classes = (dict, list, str, int, float, bool)
    obj = pickle.loads(data)
    
    if not isinstance(obj, allowed_classes):
        raise ValueError("Unsafe object type detected!")
    
    return obj

def persist_safe_object(obj):
    # Serialize the object safely
    safe_data = pickle.dumps(obj)
    
    # Store the safe_data in the database
    new_entry = YourModel(data=safe_data)  # Replace YourModel with your actual model
    session.add(new_entry)
    session.commit()

# Example usage
try:
    user_input = {'key': 'value'}  # Replace with actual user input
    persist_safe_object(user_input)
except Exception as e:
    print(f"Error: {e}")

Cite this entry

@misc{vaitp:cve202337941,
  title        = {{Apache Superset metadata db write access leads to remote code execution}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2023},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2023-37941},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2023-37941/}}
}
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 ::