Transformers save_pretrained path traversal allows arbitrary file writes through chat template names
High severity
GitHub Reviewed
Published
Aug 2, 2026
to the GitHub Advisory Database
•
Updated Sep 1, 2026
Description
Published by the National Vulnerability Database
Aug 2, 2026
Published to the GitHub Advisory Database
Aug 2, 2026
Reviewed
Sep 1, 2026
Last updated
Sep 1, 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 ofPreTrainedTokenizerBaseandProcessorMixin, where keys from thechat_templatedictionary are used directly as filenames without proper validation. An attacker can exploit this by publishing a malicious Hugging Face Hub repository with a craftedtokenizer_config.jsonfile. 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 fromProcessorMixin, including Idefics, Florence, Gemma, Phi, and Qwen-VL.References