CVE-2026-9856
High · 7.1CVSS
7.1
EPSS
0.5%
Published
Aug 2, 2026
CISA due date
—
Cloudanix analysis
Someone can trick popular AI software into secretly writing dangerous files anywhere on a computer simply by sharing a fake model online that people download.
- Exploitation
- Requires User Interaction
- Attacker needs
- None
- Complexity
- Low
- Impact
- Data Tampering
- Component
- Library
- Class
- Path Traversal
- Remediation
- Upgrade
- Effort
- Medium
- Patch risk
- Low
What it actually does
Path traversal in save_pretrained() of PreTrainedTokenizerBase and ProcessorMixin allows untrusted chat_template dictionary keys to be used directly as filenames, enabling writes of attacker-controlled content outside the intended directory.
Why it matters to the business
Attackers can overwrite arbitrary files on systems that download and save models from the Hugging Face Hub, leading to potential data corruption, service disruption, or further system compromise in AI/ML pipelines.
How an attack unfolds
An attacker publishes a malicious repository on the Hugging Face Hub containing a crafted tokenizer_config.json with path-traversal keys inside the chat_template dictionary; when a victim downloads the tokenizer or processor and invokes save_pretrained(), the unsanitized keys cause arbitrary file writes with attacker-supplied content.
How to fix it
Upgrade the transformers library to a version containing input validation for chat_template keys; until a fix is released, avoid calling save_pretrained() on objects loaded from untrusted repositories and implement strict filename sanitization in any custom wrappers.
How to confirm the fix worked
Confirm the installed transformers version is newer than 5.8.0.dev0; test save_pretrained() behavior with a crafted tokenizer_config.json containing traversal sequences such as '../' and verify that writes remain confined to the target directory.
Typical attack path
- Create and publish malicious repository on Hugging Face Hub with crafted tokenizer_config.json
- Victim downloads and loads the tokenizer or processor via the Hub
- Victim calls save_pretrained() on the loaded object
- Path traversal writes attacker-controlled files to arbitrary locations on disk
How to detect it
Review application and system logs for save_pretrained() invocations that reference tokenizer_config.json or chat_template entries; correlate with file-system audit logs showing writes containing traversal sequences or unexpected file extensions outside the model cache directory.
What your security team should do
- Pin transformers to a patched release as soon as it becomes available
- Restrict model downloads to verified organizations or repositories with signed commits
- Run model-loading workloads inside containers with read-only root filesystems and limited write paths
- Add runtime monitoring for unexpected file writes originating from save_pretrained() calls
The record
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.
Affected packages
| Ecosystem | Package | Introduced | Fixed |
|---|
Related vulnerabilities
- CVE-2026-81163 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')… CWE-22
- CVE-2026-112049 Vita3K before build 4187 contains a path traversal (zip slip) vulnerability in… CWE-22
- CVE-2026-112005 WhoDB 0.104.0 before 0.135.0 contains a path traversal vulnerability that allows remote… CWE-22
- CVE-2026-61702 OpenPrinting CUPS is an open source printing system for Linux and other Unix-like… CWE-22
- CVE-2026-104871 The Angular SSR is a server-rise rendering tool for Angular applications. CWE-22
- CVE-2026-102991 Mako is a template library written in Python. CWE-22
- CVE-2026-101894 The decompress package for Node.js extracts archives. CWE-22
- CVE-2026-100689 GitPython before 3.1.62 does not validate the `path` field read from an untrusted… CWE-22