CVE-2026-113786: pypdf Arbitrary Image Parser Invocation via Unvalidated JPEG Data
Summary
CVE-2026-113786: pypdf: Unvalidated JPEG image data loading. Affects pypdf versions < 6.21.1. Fixed in 6.21.1. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
pypdf is a Python library that allows users to manipulate PDF files, including reading, writing, and modifying PDF content. It is widely used for tasks such as merging documents, extracting text, and adding images. However, the library has a vulnerability that can lead to arbitrary image parsers being invoked when handling JPEG data, particularly when the optional Pillow dependency is not installed.
Vulnerability Detail
The vulnerability arises from the way pypdf processes JPEG images using the /DCTDecode filter. An attacker can craft a malicious PDF that exploits this flaw, potentially leading to arbitrary code execution or other unintended consequences. This vulnerability is particularly concerning for users who do not have the Pillow library installed, as they may be more susceptible to exploitation. The technical aspects involve the improper validation of image data, which allows for the invocation of arbitrary image parsers.
How To Fix
Latest published version: 6.21.2 as of 22 Oct 2026
pip install --upgrade "pypdf==6.21.2"
Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.
If you need the minimum change
6.21.1
This is the first release that contains the fix.
pip install --upgrade "pypdf==6.21.1"
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If you cannot upgrade to the patched version immediately, consider applying the changes from pull request #4222 on GitHub. This involves modifying the image loading logic to ensure that only validated JPEG data is processed.
Conclusion
The pypdf library has a vulnerability that allows for arbitrary image parser invocation through unvalidated JPEG data. Users are advised to upgrade to version 6.21.1 or later to mitigate this risk. If an upgrade is not feasible, applying the changes from the relevant pull request can serve as a temporary workaround.
See every vulnerability recorded for pypdf →
FAQ
An attacker can exploit this vulnerability to invoke arbitrary image parsers, potentially leading to code execution or other security issues.
Users of pypdf who do not have the optional Pillow dependency installed are particularly at risk.
You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.
If an upgrade is not possible, consider applying the changes from pull request #4222 to mitigate the risk.
The CVSS score for this vulnerability is 2.3, indicating a low severity level.
References
Related vulnerabilities
Recent vulnerabilities recorded for pypdf.