CVE-2025-6051: Hugging Face Transformers library has Regular Expression Denial of Service
Hugging Face Transformers before 4.53.0 has a regular expression denial of service in normalize_numbers() of the EnglishNormalizer class. A string with a long run of digits makes the regex burn CPU. Services that normalize user text, such as text-to-speech APIs, can stall. Upgrade to transformers 4.53.0.
Published Sep 14, 2025 · Updated Sep 15, 2025 · Analysis Nov 1, 2026
What an attacker can do
EnglishNormalizer.normalize_numbers() rewrites numbers in text using regular expressions. A crafted string with a long sequence of digits triggers catastrophic backtracking, so one request can hold a CPU core for a long time. The cost grows quickly with input length.
The attacker needs only the ability to submit text that reaches the normalizer. That means an API or app that feeds user text into a tokenizer using it, such as a text-to-speech service. The pull request that fixed it is titled Fix ReDOS in tokenizer digit substitution and its tests live in test_tokenization_clvp.py, which points to the CLVP tokenizer path.
The result is availability loss only: worker threads are tied up, requests time out, and a few parallel requests can exhaust a small pool. The CVSS 3.0 vector reflects network access, no privileges, no interaction and low availability impact. No data is exposed and no code runs.
Who is affected
Affected: transformers below 4.53.0, in services that pass untrusted text through number normalization (EnglishNormalizer). Offline use with trusted text is not at risk. Check the installed version:
pip show transformersAlso check lock files and container images, since the library is often pinned inside model-serving images.
transformers
- Ecosystem
- PyPI
- Affected
- < 4.53.0
- Fixed in
- 4.53.0
- Check
pip show transformers
How to fix it
Upgrade to transformers 4.53.0.
pip install --upgrade transformers==4.53.0The fix (pull request 38844) rewrites the vulnerable regexes. A maintainer comment says it uses possessive quantifiers, via the regex module on Python before 3.11 and re on 3.11 and later. The sources give no other workaround. If you cannot upgrade, cap input length and set a per-request timeout on the service that calls the tokenizer.
How to tell if you were hit
Watch for requests with unusually long digit runs followed by high CPU on the inference workers and rising latency or timeouts. A stack dump or py-spy trace showing time inside re or regex calls from EnglishNormalizer.normalize_numbers confirms the cause. Check request logs for inputs that are mostly digits.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
A Regular Expression Denial of Service (ReDoS) vulnerability was discovered in the Hugging Face Transformers library, specifically within the normalize_numbers() method of the EnglishNormalizer class. This vulnerability affects versions up to 4.52.4 and is fixed in version 4.53.0. The issue arises from the method's handling of numeric strings, which can be exploited using crafted input strings containing long sequences of digits, leading to excessive CPU consumption. This vulnerability impacts text-to-speech and number normalization tasks, potentially causing service disruption, resource exhaustion, and API vulnerabilities.
Questions
- Which version fixes CVE-2025-6051?
transformers 4.53.0. Everything below it is affected, per the advisory.
- Does this allow code execution or data theft?
No. The impact is CPU exhaustion from regex backtracking. The CVSS vector shows only low availability impact.
- Who is at risk?
Services that normalize untrusted text with EnglishNormalizer, for example text-to-speech endpoints that accept arbitrary user input.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology
More Transformers vulnerabilities
All Transformers entriesCVE-2026-80047
Hugging Face Transformers downloads custom generation code before trust consent
high7.8No fixSep 1, 2026CVE-2026-9856
Transformers save_pretrained path traversal allows arbitrary file writes through chat template names
high7.1Aug 2, 2026CVE-2026-5241
huggingface/transformers: Arbitrary Code Execution During Model Initialization in the LightGlue Model Loading Path
high8.0Jun 3, 2026CVE-2026-4372
HuggingFace transformers vulnerable to remote code execution
high7.8May 26, 2026CVE-2026-1839
HuggingFace Transformers allows for arbitrary code execution in the `Trainer` class
medium6.5Apr 7, 2026CVE-2025-6921
Hugging Face Transformers vulnerable to Regular Expression Denial of Service (ReDoS) in the AdamWeightDecay optimizer
medium5.3Sep 23, 2025
