VAITP Dataset

← Back to the dataset

CVE-2016-9949

Remote code execution in Apport < 2.20.4 via manipulated CrashDB field

  • CVSS 7.8
  • CWE-94 Improper Control of Generation of Code ('Code Injection')
  • Input Validation and Sanitization
  • Remote

An issue was discovered in Apport before 2.20.4. In apport/ui.py, Apport reads the CrashDB field and it then evaluates the field as Python code if it begins with a "{". This allows remote attackers to execute arbitrary Python code.

CVSS base score
7.8
Published
2016-12-17
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
Apport
Fixed by upgrading
Yes

Solution

Update Apport to version 2.20.4 or higher.

Vulnerable code sample

def evaluate_crashdb_field(crashdb_field):
    # Vulnerable code: directly evaluating the field as Python code
    if crashdb_field.startswith("{"):
        return eval(crashdb_field)  # This is unsafe and allows arbitrary code execution
    else:
        return crashdb_field

# Example usage
crashdb_field = "{'key': 'value'}"  # This could be malicious code
result = evaluate_crashdb_field(crashdb_field)
print(result)

Patched code sample

import json

def safe_evaluate_crashdb_field(crashdb_field):
    # Ensure that the field is a valid JSON string and does not contain executable code
    try:
        # Parse the JSON string safely
        parsed_data = json.loads(crashdb_field)

        # Proceed with using parsed_data, which is now safe
        return parsed_data
    except json.JSONDecodeError:
        # Handle the case where parsing fails
        raise ValueError("Invalid CrashDB field format")

# Example usage
crashdb_field = '{"key": "value"}'  # This should be a valid JSON string
safe_data = safe_evaluate_crashdb_field(crashdb_field)
print(safe_data)

Cite this entry

@misc{vaitp:cve20169949,
  title        = {{Remote code execution in Apport < 2.20.4 via manipulated CrashDB field}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2016},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2016-9949},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2016-9949/}}
}

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.