CVE-2026-9856: Transformers Path Traversal Vulnerability
HIGHCVE-2026-9856 is a HIGH (CVSS 7.1) path traversal vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Transformers libraries in the PyPI ecosystem. The issue involves transformers save_pretrained path traversal allows arbitrary file writes through chat template names. Remediation is available by upgrading affected packages to version 5.10.0.
CVE-2026-9856 at a Glance
Security Impact
CVSS: 7.1
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:L).
How to Fix CVE-2026-9856
To remediate this vulnerability, upgrade all affected Transformers 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 transformers>=5.10.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show transformers
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2026-9856, inspect your installed packages using pip:
pip show transformers
Analyze the terminal output to locate any version of Transformers in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.10.0), your application is affected.
Note: The pip show transformers command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Transformers, 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-9856 Affected Transformers Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
transformers
|
PyPI |
< 5.10.0
|
5.10.0
|
References
Frequently Asked Questions
What is CVE-2026-9856?
Which Transformers versions are affected?
What version fixes CVE-2026-9856?
Is transformers affected?
What is the CVSS score of CVE-2026-9856?
What CWE is associated with CVE-2026-9856?
How can I check PyPI dependencies for CVE-2026-9856?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-xrqw-3rrv-vx5w",
"modified" : "2026-09-01T18:58:08Z",
"published" : "2026-08-02T18:30:20Z",
"aliases" : [ "CVE-2026-9856" ],
"summary" : "Transformers save_pretrained path traversal allows arbitrary file writes through chat template names",
"details" : "A vulnerability in huggingface/transformers versions < 5.10.0 allows an attacker to perform arbitrary file writes via path traversal. The issue resides in the `save_pretrained()` methods of `PreTrainedTokenizerBase` and `ProcessorMixin`, where keys from the `chat_template` dictionary are used directly as filenames without proper validation. An attacker can exploit this by publishing a malicious Hugging Face Hub repository with a crafted `tokenizer_config.json` file. When a victim downloads and saves the tokenizer or processor, the attacker-controlled keys can escape the intended save directory, enabling arbitrary file writes with attacker-controlled content. This vulnerability affects multiple processors inheriting from `ProcessorMixin`, including Idefics, Florence, Gemma, Phi, and Qwen-VL.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:L"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "transformers"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "5.10.0"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-9856"
}, {
"type" : "WEB",
"url" : "https://github.com/huggingface/transformers/pull/46191"
}, {
"type" : "WEB",
"url" : "https://github.com/huggingface/transformers/commit/eaaaf8494dd5386634ae37d1d122212fdc315be5"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/huggingface/transformers"
}, {
"type" : "WEB",
"url" : "https://huntr.com/bounties/362824d5-fe18-40e8-a6cf-62277f97a170"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-22" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2026-09-01T18:58:08Z",
"nvd_published_at" : "2026-08-02T16:16:25Z"
}
}