Описание
Insecure Deserialization (pickle) in pdfminer.six CMap Loader — Local Privesc
🚀 Overview
This report demonstrates a real-world privilege escalation vulnerability in pdfminer.six due to unsafe usage of Python's pickle module for CMap file loading.
It shows how a low-privileged user can gain root access (or escalate to any service account) by exploiting insecure deserialization in a typical multi-user or server environment.

🚨 Special Note
This advisory addresses a distinct vulnerability from GHSA-wf5f-4jwr-ppcp (CVE-2025-64512).
While the previous CVE claims to mitigate issues related to unsafe deserialization, the patch introduced in commit b808ee05dd7f0c8ea8ec34bdf394d40e63501086 does not address the vulnerability reported here.
Based on testing performed against the latest version of the library (comparison view), the issue remains exploitable through local privilege escalation due to continued unsafe use of pickle files. The Dockerfile is hence modified to run test against this claim.
This demonstrates that the patch for CVE-2025-64512 is incomplete: the vulnerability remains exploitable. This advisory therefore documents a distinct, independently fixable flaw. A correct remediation must remove the dependency on pickle files (or otherwise eliminate unsafe deserialization) and replace it with a safe, auditable data-handling approach so the library can operate normally without relying on pickle
📚 Table of Contents
- 🔍 Background
- 🐍 Vulnerability Description
- 🎭 Demo Scenario
- 🧨 Technical Details
- 🔧 Setup and Usage
- 📝 Step-by-step Walkthrough
- 🛡️ Security Standards & References
🔍 Background
pdfminer.six is a popular Python library for extracting text and information from PDF files. It supports CJK (Chinese, Japanese, Korean) fonts via external CMap files, which it loads from disk using Python's pickle module.
🐍 Security Issue: If the CMap search path (
CMAP_PATHor default directories) includes a world-writable or user-writable directory, an attacker can place a malicious.pickle.gzfile that will be loaded and deserialized by pdfminer.six, leading to arbitrary code execution.
🐍 Vulnerability Description
- Component: pdfminer.six CMap loading (
pdfminer/cmapdb.py) - Issue: Loads and deserializes
.pickle.gzfiles using Python’spicklemodule, which is unsafe for untrusted data. - Exploitability: If a low-privileged user can write to any directory in
CMAP_PATH, they can execute code as the user running pdfminer—potentially root or a privileged service. - Impact: Full code execution as the service user, privilege escalation from user to root, persistence, and potential lateral movement.

🎭 Demo Scenario
Environment:
- 🐧 Alpine Linux (Docker container)
- 👨💻 Two users:
user1(attacker: low-privilege)root(victim: runs privileged PDF-processing script)
- 🗂️ Shared writable directory:
/tmp/uploads - 🛣️
CMAP_PATHset to/tmp/uploadsfor the privileged script - 📦 pdfminer.six installed system-wide
Attack Flow:
- 🕵️♂️
user1creates a malicious CMap file (Evil.pickle.gz) in/tmp/uploads. - 👑 The privileged service (
root) processes a PDF or callsget_cmap("Evil"). - 💣 The malicious pickle is deserialized, running arbitrary code as root.
- 🎯 The exploit creates a flag file in
/root/pwnedByPdfmineras proof.

🧨 Technical Details
- Vulnerability Type: Insecure deserialization of untrusted data using Python's
pickle - Attack Prerequisites: Attacker can write to a directory included in
CMAP_PATH - Vulnerable Line:
return type(str(name), (), pickle.loads(gzfile.read()))In
pdfminer/cmapdb.py's_load_datamethod - https://github.com/pdfminer/pdfminer.six/blob/20250506/pdfminer/cmapdb.py#L246
- Proof of Concept: See
createEvilPickle.py,evilmod.py, andprocessPdf.py
Exploit Chain:
- Attacker places a malicious
.pickle.gzfile in the CMap search path. - Privileged process (e.g., root) loads a CMap, triggering pickle deserialization.
- Arbitrary code executes with the privilege of the process (root/service account).

🔧 Setup and Usage
📁 Files
</> Dockerfile
</> evilmod.py
</> createEvilPickle.py
</> processPDF.py

1️⃣ Build and start the demo container
2️⃣ In the container, open two shells in parallel (or switch users in one):
🕵️♂️ Shell 1 (Attacker: user1)
👑 Shell 2 (Victim: root)
3️⃣ Proof of escalation

📝 Step-by-step Walkthrough
- user1 uses
createEvilPickle.pyto craft and place a malicious CMap pickle in a shared upload directory. - The root user runs a typical PDF-processing script, which loads CMap files from that directory.
- The exploit triggers, running arbitrary code as root.
- The attacker now has proof of code execution as root (and, in a real attack, could escalate further).

🛡️ Security Standards & References
-
CVSS (Common Vulnerability Scoring System):
- Base Score: 7.8 (High)
- Vector:
AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
-
OWASP Top 10:
- A08:2021 - Software and Data Integrity Failures
- A03:2021 - Injection (by analogy, as it's code injection via deserialization)
-
MITRE CWE References:
-
MITRE ATT&CK Techniques:
Пакеты
pdfminer.six
< 20251230
20251230
Связанные уязвимости
pdfminer.six before 20251230 contains an insecure deserialization vulnerability in the CMap loading mechanism. The library uses Python pickle to deserialize CMap cache files without validation. An attacker with the ability to place a malicious pickle file in a location accessible to the application can trigger arbitrary code execution or privilege escalation when the file is loaded by a trusted process. This is caused by an incomplete patch to CVE-2025-64512.
pdfminer.six before 20251230 contains an insecure deserialization vulnerability in the CMap loading mechanism. The library uses Python pickle to deserialize CMap cache files without validation. An attacker with the ability to place a malicious pickle file in a location accessible to the application can trigger arbitrary code execution or privilege escalation when the file is loaded by a trusted process. This is caused by an incomplete patch to CVE-2025-64512.
pdfminer.six before 20251230 contains an insecure deserialization vuln ...