CVE-2026-31826: pypdf Manipulated Stream Length Values Can Vulnerability
MODERATECVE-2026-31826 is a MODERATE manipulated stream length values can vulnerability (CWE-770: Allocation of Resources Without Limits or Throttling) affecting pypdf libraries in the PyPI ecosystem. The issue involves manipulated stream length values can exhaust ram. Remediation is available by upgrading affected packages to version 6.8.0.
CVE-2026-31826 at a Glance
How to Fix CVE-2026-31826
To remediate this vulnerability, upgrade all affected pypdf dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install pypdf>=6.8.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show pypdf
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2026-31826, inspect your installed packages using pip:
pip show pypdf
Analyze the terminal output to locate any version of pypdf in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 6.8.0), your application is affected.
Note: The pip show pypdf command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-770: Allocation of Resources Without Limits or Throttling, where the product allocates a reusable resource or group of resources on behalf of an actor without imposing any intended restrictions on the size or number of resources that can be allocated. In pypdf, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-31826 Affected pypdf Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
pypdf
|
PyPI |
< 6.8.0
|
6.8.0
|
References
Frequently Asked Questions
What is CVE-2026-31826?
Which pypdf versions are affected?
What version fixes CVE-2026-31826?
Is pypdf affected?
What CWE is associated with CVE-2026-31826?
How can I check PyPI dependencies for CVE-2026-31826?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-hqmh-ppp3-xvm7",
"modified" : "2026-03-11T05:46:57Z",
"published" : "2026-03-11T00:14:02Z",
"aliases" : [ "CVE-2026-31826" ],
"summary" : "pypdf: manipulated stream length values can exhaust RAM",
"details" : "### Impact\n\nAn attacker who uses this vulnerability can craft a PDF which leads to large memory usage. This requires parsing a content stream with a rather large `/Length` value, regardless of the actual data length inside the stream.\n\n### Patches\nThis has been fixed in [pypdf==6.8.0](https://github.com/py-pdf/pypdf/releases/tag/6.8.0).\n\n### Workarounds\nIf you cannot upgrade yet, consider applying the changes from PR [#3675](https://github.com/py-pdf/pypdf/pull/3675).\n\nAs far as we are aware, this mostly affects reading from buffers of unknown size, as returned by `open(\"file.pdf\", mode=\"rb\")` for example. Passing a file path or a `BytesIO` buffer to *pypdf* instead does not seem to trigger the vulnerability.",
"severity" : [ {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "pypdf"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "6.8.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/py-pdf/pypdf/security/advisories/GHSA-hqmh-ppp3-xvm7"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-31826"
}, {
"type" : "WEB",
"url" : "https://github.com/py-pdf/pypdf/pull/3675"
}, {
"type" : "WEB",
"url" : "https://github.com/py-pdf/pypdf/commit/3c550b3196adeba1506a26e57c09c09fac75e9aa"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/py-pdf/pypdf"
}, {
"type" : "WEB",
"url" : "https://github.com/py-pdf/pypdf/releases/tag/6.8.0"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-770" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2026-03-11T00:14:02Z",
"nvd_published_at" : "2026-03-10T22:16:20Z"
}
}