# CVE-2026-113786: pypdf unsafe image plugin selection in DCTDecode handler

Source: https://junglewise.ai/threats/cve-2026-113786-pypdf-is-a-free-and-open-source-pure-python-pdf-library-prior-to  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-10-21. Updated: 2026-10-21  
License: CC BY 4.0 with a link back

CVE-2026-113786 · Severity: medium · CVSS 4 · Published 2026-10-21

pypdf is a Python library for reading and manipulating PDF files. When processing a specially crafted PDF containing image data, the library can be tricked into invoking unintended image parsers—specifically those that run external commands like Ghostscript—leading to arbitrary code execution if Ghostscript is installed on the system.

Technologies: [Pypdf](https://junglewise.ai/threats/technologies/pypdf-pypdf), [pypdf (PyPI)](https://junglewise.ai/threats/technologies/pypdf). Vendors: [Pypdf](https://junglewise.ai/threats/vendors/pypdf), [PyPI](https://junglewise.ai/threats/vendors/pypi).

## Quick answers

**Is CVE-2026-113786 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2026-113786 being exploited in the wild.

**How severe is CVE-2026-113786?** Medium severity, with a CVSS score of 4, published 21 October 2026.

**Which products and versions are affected?** Pypdf before 6.21.1; pypdf (PyPI) < 6.21.1, ECOSYSTEM:introduced=0,fixed=6.21.1.

**Is there a fix for CVE-2026-113786?** Yes. pypdf (PyPI): upgrade to 6.21.1 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2026-113786 attacked?** It is attacked over the network, in a software library.

**Am I affected by CVE-2026-113786?** Check whether you run Pypdf or pypdf (PyPI) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- pypdf (PyPI): upgrade to 6.21.1 or later

  ```sh
  pip install "pypdf>=6.21.1"
  ```


## Technical details

The vulnerability exists in the _xobj_to_image function, which processes DCTDecode-filtered image streams. Without restricting the image format, Pillow's Image.open() sniffs the stream bytes and selects a parser based on file magic bytes rather than the declared format, allowing an attacker to embed non-JPEG data (such as EPS) that triggers external command execution via the EpsImagePlugin. The fix restricts DCTDecode processing to JPEG format only, preventing plugin confusion.

## Affected products

- pypdf pypdf before 6.21.1

## Identifiers

- CVE-2026-113786
- GHSA-5hx5-vpf9-5wcv

## Timeline

- 2026-10-21: disclosed
- 2026-10-17: patched

## References

- [https://github.com/py-pdf/pypdf/commit/512d8eb94eb04be1d1c90504e6da2dcef8679e07](https://github.com/py-pdf/pypdf/commit/512d8eb94eb04be1d1c90504e6da2dcef8679e07)
- [https://github.com/py-pdf/pypdf/pull/4222](https://github.com/py-pdf/pypdf/pull/4222)

## Related threats

- [pypdf memory exhaustion in cross-reference stream parsing](https://junglewise.ai/threats/cve-2026-119209-pypdf-is-a-free-and-open-source-pure-python-pdf-library-prior-to)
- [pypdf denial of service via forged encrypted PDF page count](https://junglewise.ai/threats/cve-2026-119208-pypdf-is-a-free-and-open-source-pure-python-pdf-library-prior-to)
- [pypdf excessive memory consumption in strict mode PDF parsing](https://junglewise.ai/threats/cve-2026-119207-pypdf-is-a-free-and-open-source-pure-python-pdf-library-prior-to)
- [pypdf denial of service via crafted page labels](https://junglewise.ai/threats/cve-2026-119206-pypdf-is-a-free-and-open-source-pure-python-pdf-library-prior-to)
- [pypdf infinite loop in DictionaryObject cloning](https://junglewise.ai/threats/cve-2026-119205-pypdf-is-a-free-and-open-source-pure-python-pdf-library-prior-to)
