VAITP Dataset

← Back to the dataset

CVE-2024-52004

Insufficient input validation in MediaCMS allows remote code execution.

  • CVSS 8.7
  • CWE-74
  • Input Validation and Sanitization
  • Remote

MediaCMS is an open source video and media CMS, written in Python/Django and React, featuring a REST API. MediaCMS has been prone to vulnerabilities that upon special cases can lead to remote code execution. All versions before v4.1.0 are susceptible, and users are highly recommended to upgrade. The vulnerabilities are related with insufficient input validation while uploading media content. The condition to exploit the vulnerability is that the portal allows users to upload content. This issue has been patched in version 4.1.0. There are no known workarounds for this vulnerability.

CVSS base score
8.7
Published
2024-11-08
OWASP
A01 Broken Access Control
Orthogonal defect classification
Checking
Code defect classification
Missing Check
Category
Input Validation and Sanitization
Subcategory
Command Injection
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Affected component
MediaCMS

Solution

Upgrade to MediaCMS version 4.1.0 or later.

Vulnerable code sample

import os
import subprocess
from django.core.files.storage import default_storage

def handle_uploaded_media(file):
    # Save the uploaded file to a temporary location
    path = default_storage.save(file.name, file)
    full_path = os.path.join(default_storage.location, path)

    # VULNERABLE: command injection via unsanitized filename
    subprocess.call(f"ffmpeg -i {full_path} -c copy /tmp/processed_{file.name}")

    return f"/media/{path}"

Patched code sample

import os
import subprocess
import shlex
from django.core.files.storage import default_storage

def handle_uploaded_media(file):
    # Save the uploaded file to a temporary location
    path = default_storage.save(file.name, file)
    full_path = os.path.join(default_storage.location, path)

    # FIX: pass arguments as a list to avoid injection
    subprocess.run([
        "ffmpeg",
        "-i", full_path,
        "-c", "copy",
        f"/tmp/processed_{file.name}"
    ], check=True)

    return f"/media/{path}"

Payload

# Example of a malicious Python script payload disguised as a video file
# This payload could be named "malicious.mp4" but actually contains Python code

import os
import subprocess

# This code would execute a command on the server
subprocess.call(["/bin/bash", "-c", "echo 'Malicious code executed' > /tmp/malicious.txt"])

Cite this entry

@misc{vaitp:cve202452004,
  title        = {{Insufficient input validation in MediaCMS allows remote code execution.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2024},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2024-52004},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2024-52004/}}
}

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.