Skip to content
TransformersGHSA-xrqw-3rrv-vx5w

Transformers save_pretrained path traversal allows arbitrary file writes through chat template names

High7.1CVE-2026-9856 · Published Aug 2, 2026 · updated Sep 10, 2026

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.

GitHub advisory

Affected versions

PackageAffectedFixed in
transformers
PyPI
< 5.10.05.10.0
Details and references

More Transformers advisories

All Transformers
Advisory
Transformers: code execution
High8.0Jun 3
HuggingFace transformers vulnerable to remote code execution
High7.8May 26
HuggingFace Transformers allows for arbitrary code execution in the `Trainer` class
Medium6.5Apr 7
Transformers: code injection
High7.8Dec 23, 2025
Transformers: unsafe deserialization
High7.8Dec 23, 2025
Transformers: unsafe deserialization
High7.8Dec 23, 2025

Critical advisories by email

Wednesdays: the week’s critical and high advisories in the AI and data stack, with the fixed versions. Only in weeks that have some.

Double opt-in. Unsubscribe any time.