CVE-2025-6051: Hugging Face Transformers Library Regular Expression Denial of Service Vulnerability

transformers Updated 02 Oct 2025

Summary

14/09/2025
Yes i
Moderate
5.3

CVE-2025-6051: Hugging Face Transformers library has Regular Expression Denial of Service. 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 Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

The Hugging Face Transformers library is a widely used open-source library for natural language processing tasks, including text generation, translation, and text-to-speech. It provides pre-trained models and tools for working with various languages and tasks. The library is known for its ease of use and integration with popular machine learning frameworks. However, it has been found to have a vulnerability that affects its number normalization functionality, which is critical for tasks that involve numeric data processing.

Vulnerability Detail

A Regular Expression Denial of Service (ReDoS) vulnerability exists in the Hugging Face Transformers library, specifically in the normalize_numbers() method of the EnglishNormalizer class. This vulnerability affects versions up to 4.52.4 and is addressed in version 4.53.0. The issue arises from the method's handling of numeric strings, which can be exploited by providing crafted input strings with long sequences of digits. This can lead to excessive CPU consumption, causing service disruptions, resource exhaustion, and potential API vulnerabilities in applications relying on this library.

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

If you cannot immediately update the library, consider implementing input validation to limit the length of numeric strings processed by the normalize_numbers() method. This can help mitigate the risk of excessive CPU consumption. For example, you can restrict input to a maximum length of 10 digits before passing it to the method.

Conclusion

The Hugging Face Transformers library has a ReDoS vulnerability that affects its number normalization functionality. It is crucial for users of the library to update to version 4.53.0 or later to mitigate this risk. Additionally, implementing input validation can serve as a temporary workaround until the library is updated.

See every vulnerability recorded for transformers →

Share this vulnerability

FAQ

A ReDoS vulnerability occurs when an application processes user input with regular expressions in a way that can lead to excessive resource consumption, often causing the application to slow down or crash.

Versions of the Hugging Face Transformers library up to 4.52.4 are affected by this vulnerability. The issue is fixed in version 4.53.0.

You can use Vulert, a tool that monitors and alerts for open-source vulnerabilities in your software. By uploading your Pipfile.lock to Vulert, you can check for vulnerabilities without needing to access the code directly.

The vulnerability can lead to excessive CPU usage, service disruptions, and resource exhaustion, which can affect the performance and availability of applications using the library.

Yes, you can implement input validation to limit the length of numeric strings processed by the normalize_numbers() method, which can help reduce the risk of CPU exhaustion.

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