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.
Published: 2026-08-02
Score: 7.1 High
EPSS: < 1% Very Low
KEV: No
Impact: n/a
Action: n/a
AI Analysis

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.

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

Remediation

No vendor fix or workaround currently provided.

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

No advisories yet.

History

Mon, 03 Aug 2026 15:30:00 +0000

Type Values Removed Values Added
Metrics ssvc

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


Sun, 02 Aug 2026 19:15:00 +0000

Type Values Removed Values Added
First Time appeared Huggingface
Huggingface transformers
Vendors & Products Huggingface
Huggingface transformers

Sun, 02 Aug 2026 15:45:00 +0000

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'}


Subscriptions

Huggingface Transformers
cve-icon MITRE

Status: PUBLISHED

Assigner: @huntr_ai

Published:

Updated: 2026-08-03T14:57:43.370Z

Reserved: 2026-05-28T15:41:24.076Z

Link: CVE-2026-9856

cve-icon Vulnrichment

Updated: 2026-08-03T14:57:37.440Z

cve-icon NVD

Status : Received

Published: 2026-08-02T16:16:25.413

Modified: 2026-08-03T16:16:33.040

Link: CVE-2026-9856

cve-icon Redhat

No data.

cve-icon OpenCVE Enrichment

Updated: 2026-08-03T09:15:03Z

Weaknesses
  • CWE-22

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