/

CVE-2026-54071

Severity:

HIGH RISK

(7.8)

Unsafe Pickle Deserialization (CWE-502) in BabelDOC

CVE-2026-54071

Deferred

Vulnerability type

Category:

Unsafe Deserialization

CWE:

CWE-502

Impact:

Arbitrary Code Execution

Severity:

HIGH RISK

(7.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

BabelDOC's vendored PDF parser can deserialize attacker-controlled pickle data while loading CMap files selected from PDF-controlled values. If a PDF can influence the resolved CMap path to an attacker-writable pickle file, arbitrary Python code may execute with the privileges of the BabelDOC process.

Affected context

The vulnerability occurs in BabelDOC deployments using the affected vendored PDF parser and processing PDFs that control Encoding, CMapName, or embedded PostScript usecmap references. After path separators are decoded, incomplete name normalization and path construction may allow CMap resolution to escape trusted directories and reach an attacker-writable .pickle.gz file.

Exploit preconditions

  • Attack surface: PDF processing and CMap file loading in the BabelDOC parser
  • Required access: Ability to provide or cause processing of a malicious PDF, plus access to a reachable attacker-writable pickle file path
  • Trigger point: CMap loading through CMapDB._load_data()
  • Why exploitation is possible: PDF-controlled names can influence path resolution, and the selected compressed pickle data is passed to pickle.loads() without a safe data-only restriction

Why this happens

The underlying bug combines unsafe deserialization with insufficient path canonicalization. CMap names are only partially normalized, while decoded separators and path traversal sequences can influence os.path.join() and escape intended directories. When the resulting file is loaded, Python pickle deserialization can instantiate objects or invoke behavior during reconstruction, mapping the issue to CWE-502: Deserialization of Untrusted Data.

Potential impact

  • Arbitrary Python code may execute in the BabelDOC process
  • The host or container could be compromised with the process account's privileges
  • Confidential documents or translation data could be accessed or modified
  • Processing availability could be disrupted
  • Compromised environments could be used for further lateral movement

General mitigation guidance

Mitigation generally focuses on removing executable deserialization from document-controlled workflows and enforcing strict file-boundary controls.

Common defensive patterns include:

  • Use a data-only parser or a restricted serialization format instead of Python pickle
  • Treat all PDF-derived CMap and encoding names as untrusted input
  • Canonicalize paths and verify that resolved files remain within an explicitly trusted directory
  • Reject absolute paths, traversal components, decoded separators, and unexpected file extensions
  • Keep CMap resources immutable and inaccessible to untrusted writers
  • Run document processing with least privilege, filesystem isolation, and appropriate sandboxing
  • Apply resource and process restrictions so parser compromise has limited impact

How teams detect issues like this

Organizations can look for:

  • Static analysis findings involving pickle.loads(), pickle-based loaders, or deserialization of compressed file content
  • Code review signals where document metadata controls filesystem paths
  • Missing canonical-path containment checks after URL, escape, or separator decoding
  • Tests that supply traversal sequences, absolute paths, unusual CMap names, and embedded usecmap references
  • Runtime monitoring for unexpected child processes, filesystem access outside approved CMap directories, or anomalous network activity
  • Policy enforcement that blocks executable serialization formats in untrusted document-processing components

Automated code review and dependency-analysis tools may help identify unsafe deserialization patterns and affected parser components.

Sources

SourceLink
github.comgithub.com/funstory-ai/BabelDOC/blob/main/docs/release-notes/v0.6.3.md
github.comgithub.com/funstory-ai/BabelDOC/commit/28f784ca6b437dbba040bfd9c67110373cd0924b
github.comgithub.com/funstory-ai/BabelDOC/releases/tag/v0.6.3
github.comgithub.com/funstory-ai/BabelDOC/security/advisories/GHSA-m8gf-v64p-gfmg

Frequently asked

questions

It can be reached through a malicious PDF submitted to a service or workflow that processes untrusted documents. Exploitation also depends on whether the parser can access an attacker-writable pickle file through the manipulated CMap path.

The attacker generally needs to provide a crafted PDF and have a suitable writable or otherwise controllable file available at a path the parser can resolve. The exact access depends on the deployment's file permissions and document-ingestion architecture.

Avoid deserializing Python pickle data from document-controlled paths. Use a non-executable, data-only format and enforce canonical-path containment within trusted resource directories.

Treat document metadata as untrusted, validate and constrain all derived paths, keep resource directories immutable, and run parsers with minimal filesystem and operating-system privileges.

Find out what's already
exploitable in your codebase.