VAITP Dataset

← Back to the dataset

CVE-2014-3539

Remote code execution via unsafe pickle.load in Rope library (Python)

  • CVSS 9.8
  • CWE-502
  • Resource Management
  • Remote

base/oi/doa.py in the Rope library in CPython (aka Python) allows remote attackers to execute arbitrary code by leveraging an unsafe call to pickle.load.

CVSS base score
9.8
Published
2018-04-06
OWASP
A06 Vulnerable and Outdated Components
Orthogonal defect classification
Function
Code defect classification
Incorrect Functionality
Category
Resource Management
Subcategory
Memory Leaks
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Affected component
Rope
Fixed by upgrading
Yes

Solution

Update CPython to a version that fixes the vulnerability.

Vulnerable code sample

import pickle

# Unsafe loading function that allows arbitrary code execution
def unsafe_load(file):
    return pickle.load(file)

# Example usage
with open('data.pkl', 'rb') as f:
    data = unsafe_load(f)

Patched code sample

import pickle

# Safe loading function that restricts the types that can be loaded
def safe_load(file):
    # Use a restricted set of classes to avoid arbitrary code execution
    allowed_classes = (YourAllowedClass1, YourAllowedClass2)
    return pickle.load(file, fix_imports=True, encoding="ASCII", errors="strict", 
                       loaders=(pickle.Unpickler, allowed_classes))

# Example usage
with open('data.pkl', 'rb') as f:
    data = safe_load(f)

Published fix

Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.

  • Perform signature verification on pickled data transferred over sockets (#251) (python-rope/rope)
    rope/base/oi/doa.py, rope/base/oi/doa.py · _SocketReceiver.get_send_info, rope/base/oi/doa.py · _SocketReceiver.receive_data, rope/base/oi/doa.py · _SocketReceiver.__init__, rope/base/oi/runmod.py · __rope_start_everything, rope/base/project.py, ropetest/__init__.py, ropetest/__init__.py · suite

Cite this entry

@misc{vaitp:cve20143539,
  title        = {{Remote code execution via unsafe pickle.load in Rope library (Python)}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2018},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2014-3539},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2014-3539/}}
}

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.