CVE-2026-9856

Path Traversal in huggingface/transformers

Published Aug 2, 2026 CVSS 3.0 · 7.1 High EPSS < 1% KEV · Not listed
Description
A vulnerability in huggingface/transformers versions <=5.8.0.dev0 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.

Analysis

AI-generated

Technical impact

A path traversal flaw in the `save_pretrained()` methods of PreTrainedTokenizerBase and ProcessorMixin allows an attacker to write arbitrary files with attacker‑controlled content. The flaw arises because keys from the chat_template dictionary are used directly as filenames without validation, which satisfies the criteria of CWE‑22. An exploit would let the attacker overwrite or create files outside the intended directory, potentially compromising system integrity or installing malicious payloads.

Affected Systems

The vulnerability affects the huggingface/transformers library in versions up to and including 5.8.0.dev0. Any processor that inherits from ProcessorMixin—such as Idefics, Florence, Gemma, Phi, and Qwen‑VL—is also impacted.

Risk and Exploitability

The CVSS score of 7.1 indicates moderate severity. EPSS data is not available, and the vulnerability is not listed in CISA KEV, suggesting no current widespread exploitation reports. The likely attack vector involves an attacker publishing a malicious repository on the Hugging Face Hub with a crafted tokenizer_config.json. A victim who downloads and saves the tokenizer or processor will trigger the vulnerable code and be able to write files arbitrarily through the exposed path traversal. The exploit requires the victim to interpolate the injected keys during the save operation, which typically occurs when standard library routines are called without additional defensive checks.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Apply the latest patch that removes unchecked filename usage from save_pretrained in PreTrainedTokenizerBase and ProcessorMixin.
  • If an upgrade is not immediately possible, implement a pre‑deployment check that strips or rejects any chatter_template keys containing slashes or path traversal sequences before the save_pretrained execution.
  • Configure or audit your Hugging Face Hub access so that only trusted repositories are allowed; manually review tokenizer_config.json files from unverified sources for potential traversal content.

Generated by OpenCVE AI on August 3, 2026 at 09:11 UTC.

Tracking

Sign in to view the affected projects.

Advisories

Source ID Title
Github GHSA Github GHSA GHSA-xrqw-3rrv-vx5w Transformers save_pretrained path traversal allows arbitrary file writes through chat template names
History
Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'no', 'Exploitation': 'none', 'Technical Impact': 'partial'}, 'version': '2.0.3'}

Type Values Removed Values Added
First Time appeared Huggingface
Huggingface transformers
Vendors & Products Huggingface
Huggingface transformers
Type Values Removed Values Added
Description A vulnerability in huggingface/transformers versions <=5.8.0.dev0 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.
Title Path Traversal in huggingface/transformers
Weaknesses CWE-22
References
Metrics cvssV3_0

{'score': 7.1, 'vector': 'CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:L'}

Weaknesses
  • CWE-22

    Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')

Sources

Status
PUBLISHED
Assigner
@huntr_ai
Published
Updated
Aug 3, 2026, 2:57 PM
Reserved
May 28, 2026, 3:41 PM
Status
Awaiting Analysis
Published
Aug 2, 2026, 4:16 PM
Modified
Oct 23, 2026, 10:10 PM