CVE-2026-82035 in PyMuPDF
Summary
by MITRE • 09/14/2026
PyMuPDF through 1.28.2, fixed in commit b2c8f3a, contains a path traversal vulnerability in the font branch of extract_objects() in src/__main__.py, where the output filename is constructed by joining a document-controlled BaseFont name directly onto the user-supplied output directory without stripping path separators or dot-dot sequences. Attackers can supply a crafted PDF, EPUB, XPS, or FB2 file with a BaseFont name containing encoded path separators that decode to ../ sequences or absolute paths, causing arbitrary file writes outside the intended output directory without requiring authentication or elevated privileges.
If you want to get the best quality for vulnerability data then you always have to consider VulDB.
Analysis
by VulDB Data Team • 09/14/2026
The vulnerability identified in PyMuPDF versions through 1.28.2 represents a critical path traversal flaw located within the font extraction functionality of the library's main module. Specifically, the defect resides in the extract_objects() method when processing the font branch of document parsing operations. The core technical failure stems from improper handling of user-supplied input data during file system path construction. When PyMuPDF processes documents such as PDFs, EPUBs, XPS files, or FB2 formats, it extracts embedded fonts and attempts to save them to a directory specified by the application developer or end-user. The implementation constructs the output filename by directly concatenating the BaseFont name retrieved from the document metadata with the user-provided output directory path. Crucially, this process fails to sanitize the BaseFont string for malicious sequences such as double-dot (..) path separators or absolute path indicators before joining them into a single file system path.
This lack of input validation allows an attacker who controls the content of the source document to dictate where files are written on the host operating system's file hierarchy. By embedding specific characters within the BaseFont name field that decode to relative parent directory references (../) or absolute paths, an adversary can bypass the intended output directory boundary. For instance, if a user supplies /home/user/fonts as the output directory and the document contains a font with a BaseFont value of ../../etc/passwd, the resulting path resolution will write the extracted file to /etc/passwd rather than within the fonts folder. This behavior is consistent with CWE-22: Improper Limitation of a Pathname to a Restricted Directory, which describes vulnerabilities where software does not properly neutralize special elements that can cause paths to transition outside of restricted directories.
The operational impact of this vulnerability is significant due to its potential for arbitrary file write operations without authentication or elevated privileges. Since PyMuPDF is often used in server-side applications to process uploaded documents, an attacker could exploit this flaw by uploading a crafted document containing the malicious BaseFont string. If the application processes this upload and attempts to extract fonts using a writable directory controlled by the web service account, the vulnerability can be leveraged to overwrite critical system files, inject executable code into script directories, or disrupt services by corrupting configuration files. In environments where PyMuPDF runs with limited permissions, the impact may be restricted to denial of service through file corruption; however, in less constrained environments, this flaw provides a direct vector for remote code execution if combined with other vulnerabilities such as arbitrary file inclusion or when writable directories contain interpretable script files like PHP, Python, or shell scripts.
Mitigation strategies must focus on both immediate patching and long-term defensive coding practices. The primary remediation is to upgrade PyMuPDF to version 1.28.3 or later, where commit b2c8f3a addresses this issue by implementing proper sanitization of the BaseFont name before path construction. Developers should ensure that any extracted filenames are validated against a whitelist of allowed characters and stripped of all directory traversal sequences such as .. and /. Additionally, applications utilizing PyMuPDF for document processing should enforce strict output directory restrictions using operating system-level controls like chroot jails or containerized environments to limit the blast radius even if path traversal occurs. From an offensive security perspective, this vulnerability aligns with ATT&CK technique T1048: Exfiltration Over Alternative Protocol if used for data exfiltration via file placement in accessible locations, though its primary classification remains as a local privilege escalation or arbitrary write vector depending on the execution context. Security teams should audit their document processing pipelines to ensure that no other components rely on unsanitized metadata from external documents for file system operations.