VAITP Dataset

← Back to the dataset

CVE-2018-7889

Calibre 3.18: Remote code execution via crafted .pickle file

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

gui2/viewer/bookmarkmanager.py in Calibre 3.18 calls cPickle.load on imported bookmark data, which allows remote attackers to execute arbitrary code via a crafted .pickle file, as demonstrated by Python code that contains an os.system call.

CVSS base score
7.8
Published
2018-03-08
OWASP
A08 Software and Data Integrity Failures
Orthogonal defect classification
Timing/Serialization
Code defect classification
Serialization Issues
Category
Input Validation and Sanitization
Subcategory
Insecure Parsing or Deserialization
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Affected component
Calibre
Fixed by upgrading
Yes

Solution

Update Calibre to version 3.19 or higher.

Vulnerable code sample

import cPickle

def load_bookmarks(file_path):
    with open(file_path, 'rb') as f:
        # Vulnerable code that allows arbitrary code execution via crafted .pickle files
        return cPickle.load(f)

# Example usage
# bookmarks = load_bookmarks('path/to/bookmarks.pickle')

Patched code sample

import pickle

def safe_load_pickle(file_path):
    with open(file_path, 'rb') as f:
        # Use a safer loading method that restricts the classes that can be deserialized
        return pickle.load(f, fix_imports=True, encoding="ASCII", errors="strict")

# Example usage
# bookmarks = safe_load_pickle('path/to/bookmarks.pickle')

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.

Cite this entry

@misc{vaitp:cve20187889,
  title        = {{Calibre 3.18: Remote code execution via crafted .pickle file}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2018},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2018-7889},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2018-7889/}}
}

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.