CVE-2025-5197: Regular Expression Denial of Service (ReDoS) in huggingface/transformers
A Regular Expression Denial of Service (ReDoS) vulnerability exists in the Hugging Face Transformers library, specifically in the converttfweightnametoptweightname() function. This function, responsible for converting TensorFlow weight names to PyTorch format, uses a regex pattern /[^/]([^/])/ that can be exploited to cause excessive CPU consumption through crafted input strings due to catastrophic backtracking. The vulnerability affects versions up to 4.51.3 and is fixed in version 4.53.0. This issue can lead to service disruption, resource exhaustion, and potential API service vulnerabilities, impacting model conversion processes between TensorFlow and PyTorch formats.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
pip/transformersto a version that resolves this vulnerability.Fixed in 4.53.0 - Upgrade
Upgrade
huggingface/transformersto a version that resolves this vulnerability.Fixed in 4.53.0
Event History
Frequently Asked Questions
What is the severity of CVE-2025-5197?
CVE-2025-5197 is classified as a Regular Expression Denial of Service (ReDoS) vulnerability.
How do I fix CVE-2025-5197?
To fix CVE-2025-5197, you should update the Hugging Face Transformers library to version 4.51.4 or later.
What software is affected by CVE-2025-5197?
CVE-2025-5197 affects the Hugging Face Transformers library versions up to and including 4.51.3.
What function in the Hugging Face Transformers library is vulnerable in CVE-2025-5197?
The vulnerable function in CVE-2025-5197 is `convert_tf_weight_name_to_pt_weight_name()`.
What type of attack can CVE-2025-5197 facilitate?
CVE-2025-5197 can facilitate a Denial of Service (DoS) attack through Regular Expression parsing.