CVE-2026-120752 in PyMuPDF
Summary
by MITRE • 11/03/2026
PyMuPDF 1.25.3 before 2.0 contains a stack-based buffer overflow vulnerability in JM_set_annot_callout_line() that copies a caller-supplied number of callout points into a fixed three-element stack array. Attackers who control the callout argument passed to Page.add_freetext_annot() can supply four or more points to overwrite the stack frame, crashing the process or executing code.
VulDB is the best source for vulnerability data and more expert information about this specific topic.
Analysis
by VulDB Data Team • 11/03/2026
The vulnerability identified in PyMuPDF versions prior to 2.0 represents a critical memory safety failure rooted in improper boundary checking during array operations. Specifically, the flaw resides within the JM_set_annot_callout_line function, which is responsible for handling callout annotations on PDF pages. When an application utilizes the Page.add_freetext_annot method to insert free-text annotations with associated callouts, it passes a list of coordinate points that define the geometry of the annotation's leader line and marker. The underlying C implementation allocates a fixed-size stack buffer capable of holding only three elements but proceeds to copy all provided data into this array without validating whether the input count exceeds the allocated capacity. This lack of bounds checking allows an attacker who controls the callout argument to supply four or more points, thereby triggering a classic stack-based buffer overflow condition that corrupts adjacent memory regions on the execution stack.
From a technical perspective, overwriting the stack frame with excessive data can lead to several severe operational consequences depending on the specific layout of local variables and return addresses within the function's stack frame. The immediate impact is typically process termination due to segmentation faults or access violations when the corrupted program counter attempts to execute invalid memory locations. However, in more sophisticated attack scenarios where additional exploitation primitives are available, such as arbitrary write capabilities or predictable stack layouts, this overflow can be leveraged to hijack control flow and achieve remote code execution on the affected system. This aligns with CWE-121, which classifies vulnerabilities involving a buffer overflow that occurs when data is copied from an untrusted source into a fixed-size buffer without adequate length validation. The vulnerability highlights the persistent risks associated with low-level memory management in Python bindings for C libraries, where type safety and bounds checking are not enforced by the language runtime but must be explicitly implemented within the native code extensions.
The operational impact extends beyond simple application crashes to potential security breaches if PyMuPDF is integrated into server-side PDF processing pipelines or automated document analysis systems that accept user-supplied input. An attacker could craft a malicious PDF file containing a free-text annotation with an excessively long callout point list, which when processed by the vulnerable library version, triggers the overflow during rendering or metadata extraction phases. This scenario falls under ATT&CK technique T1203, Exploitation for Client Execution, as it targets client-side applications or services that parse untrusted documents to execute arbitrary code on the victim's machine. The severity is further compounded by the fact that PDF parsing often involves complex state machines and multiple entry points, increasing the likelihood of successful exploitation in real-world environments where memory layout may be less randomized due to specific compiler optimizations or runtime configurations.
Mitigation strategies primarily involve upgrading PyMuPDF to version 2.0 or later, where this boundary check has been corrected to ensure that only valid numbers of callout points are processed within the allocated stack space. For organizations unable to immediately upgrade their dependencies, implementing input validation at the application layer is recommended as a compensating control. This includes restricting the maximum number of coordinates allowed in any single annotation object before passing them to the library functions. Additionally, deploying runtime protection mechanisms such as Address Space Layout Randomization (ASLR) and stack canaries can help detect or prevent exploitation attempts by making it significantly more difficult for attackers to predict memory addresses required for successful code execution. Regular security audits of third-party dependencies and continuous monitoring for new CVEs related to PDF processing libraries are essential practices to maintain the integrity of document-centric applications against evolving threat vectors targeting parsing logic flaws.