CVE-2025-5197: Hugging Face Transformers Regular Expression Denial of Service (ReDoS) Vulnerability

transformers Updated 02 Oct 2025

Summary

06/08/2025
Yes i
Moderate
5.3

CVE-2025-5197: Hugging Face Transformers Regular Expression Denial of Service (ReDoS) vulnerability. Affects transformers versions < 4.53.0. Fixed in 4.53.0. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

The Hugging Face Transformers library is a widely used open-source library that facilitates the use of state-of-the-art natural language processing models. It allows users to easily convert models between different frameworks, such as TensorFlow and PyTorch. The library is known for its flexibility and extensive model support, making it a popular choice among developers and researchers in the AI community. However, it has been found to contain a vulnerability that can lead to Denial of Service (DoS) attacks through regular expressions.

Vulnerability Detail

A Regular Expression Denial of Service (ReDoS) vulnerability exists in the Hugging Face Transformers library, specifically in the convert_tf_weight_name_to_pt_weight_name() function. This function 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 can lead to service disruption, resource exhaustion, and potential API service vulnerabilities, impacting model conversion processes between TensorFlow and PyTorch formats.

How To Fix

Latest published version: 5.20.2 as of 22 Oct 2026

pip install --upgrade "transformers==5.20.2"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

4.53.0

This is the first release that contains the fix.

pip install --upgrade "transformers==4.53.0"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary workaround, avoid using the convert_tf_weight_name_to_pt_weight_name() function with untrusted input. Validate and sanitize any input strings before processing them to mitigate the risk of triggering the vulnerability.

Conclusion

The Hugging Face Transformers library has a vulnerability that can lead to Denial of Service attacks through regular expressions. It is crucial for users to update to version 4.53.0 or later to mitigate this risk. Additionally, employing workarounds and monitoring tools like Vulert can help safeguard applications from potential threats.

See every vulnerability recorded for transformers →

Share this vulnerability

FAQ

The CVSS score of this vulnerability is 5.3, indicating a moderate severity level.

Versions up to 4.51.3 of the Hugging Face Transformers library are affected by this vulnerability.

You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without requiring any signup.

The potential consequences include service disruption, resource exhaustion, and vulnerabilities in API services, which can impact model conversion processes.

Yes, Vulert can monitor and alert you in real-time for open-source vulnerabilities in your software using just the Pipfile.lock.

Related vulnerabilities

Recent vulnerabilities recorded for transformers.

How To Fix

Latest published version: 5.20.2 as of 22 Oct 2026

pip install --upgrade "transformers==5.20.2"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

4.53.0

This is the first release that contains the fix.

pip install --upgrade "transformers==4.53.0"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback