VAITP Dataset

← Back to the dataset

CVE-2015-5242

OpenStack Swift-on-File allows remote users to execute arbitrary code via crafted extended attributes

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

OpenStack Swift-on-File (aka Swiftonfile) does not properly restrict use of the pickle Python module when loading metadata, which allows remote authenticated users to execute arbitrary code via a crafted extended attribute (xattrs).

CVSS base score
6.0
Published
2015-11-25
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
Affected component
swift
Fixed by upgrading
Yes

Solution

Update OpenStack Swift-on-File to a version that properly restricts the use of the pickle Python module.

Vulnerable code sample

import pickle

def load_metadata(xattrs):
    metadata = {}
    for key, value in xattrs.items():
        if key.startswith('user.'):
            # Using pickle to load metadata, which is unsafe
            try:
                metadata[key] = pickle.loads(value)
            except (pickle.UnpicklingError, EOFError, AttributeError):
                # Handle errors during unpickling
                continue
    return metadata

# Example usage
xattrs = {
    'user.metadata': b'cos\nsystem\nexec\n(S\'echo vulnerable\'\n.'
}

metadata = load_metadata(xattrs)
print(metadata)

Patched code sample

import json
import os

def safe_load_metadata(xattrs):
    # Instead of using pickle, which is unsafe, we use json to load metadata
    metadata = {}
    for key, value in xattrs.items():
        if key.startswith('user.'):
            try:
                # Assuming the metadata is stored as JSON strings
                metadata[key] = json.loads(value)
            except json.JSONDecodeError:
                # Handle the case where the JSON is invalid
                continue
    return metadata

# Example usage
xattrs = {
    'user.metadata': '{"key1": "value1", "key2": "value2"}'
}

metadata = safe_load_metadata(xattrs)
print(metadata)

Cite this entry

@misc{vaitp:cve20155242,
  title        = {{OpenStack Swift-on-File allows remote users to execute arbitrary code via crafted extended attributes}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2015},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2015-5242},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2015-5242/}}
}

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.