GHSA-qq3j-4f4f-9583 CVE-2025-2099 PYSEC-2025-40
Hugging Face Transformers Regular Expression Denial of Service
- Severity
- 5.3 / 10
- High · CVSS 3.0
- Exploit chance (EPSS)
- 0.61%
- Chance of exploitation in the next 30 days. Higher than 49.08% of scored vulnerabilities.
- Known exploited
- No
- Not in CISA's catalog
- Weakness
- CWE-1333 Inefficient Regular Expression Complexity
- Fix
4.50.0- Upgrade transformers to this version or later
Description
A Regular Expression Denial of Service (ReDoS) exists in the preprocess_string() function of the transformers.testing_utils module. In versions before 4.50.0, the regex used to process code blocks in docstrings contains nested quantifiers that can trigger catastrophic backtracking when given inputs with many newline characters. An attacker who can supply such input to preprocess_string() (or code paths that call it) can force excessive CPU usage and degrade availability.
Fix: released in 4.50.0, which rewrites the regex to avoid the inefficient pattern. ([GitHub][1])
- Affected:
< 4.50.0 - Patched:
4.50.0
Affected versions
PyPI
| Package | Vulnerable | Fixed in |
|---|---|---|
| transformers | < 4.50.0 |
4.50.0 |
| transformers | < 4.49.0 |
4.49.0 |
How to fix
Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.
transformers PyPI → 4.50.0
- pip
pip install --upgrade "transformers>=4.50.0"- poetry
poetry add "transformers>=4.50.0"- uv
uv add "transformers>=4.50.0"
Severity breakdown
CVSS 3.0 5.3
CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
- Attack vector
- Network
- Attack complexity
- Low
- Privileges required
- None
- User interaction
- None
- Scope
- Unchanged
- Confidentiality
- None
- Integrity
- None
- Availability
- Low
Weakness
CWE-1333: Inefficient Regular Expression Complexity
The product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential.
How to prevent it
- Architecture and Design: Use regular expressions that do not support backtracking, e.g. by removing nested quantifiers.
- System Configuration: Set backtracking limits in the configuration of the regular expression implementation, such as PHP's pcre.backtrack_limit. Also consider limits on execution time for the process.
- Implementation: Do not use regular expressions with untrusted input. If regular expressions must be used, avoid using backtracking in the expression.
- Implementation: Limit the length of the input that the regular expression will process.
References
Advisories
Packages
Other links
Timeline
- Published
- Last updated by the source
- Latest EPSS score
Related advisories
| Advisory | Severity | Why it's related |
|---|---|---|
| GHSA-x9r9-c232-4q39 Hugging Face Transformers downloads custom generation code before trust consent | High | Also affects transformers |
| GHSA-xrqw-3rrv-vx5w Transformers save_pretrained path traversal allows arbitrary file writes through chat template names | High | Also affects transformers |
| GHSA-fgcw-684q-jj6r huggingface/transformers: Arbitrary Code Execution During Model Initialization in the LightGlue Model Loading Path | Critical | Also affects transformers |
| GHSA-29pf-2h5f-8g72 HuggingFace transformers vulnerable to remote code execution | High | Also affects transformers |
| GHSA-69w3-r845-3855 HuggingFace Transformers allows for arbitrary code execution in the `Trainer` class | High | Also affects transformers |
| PYSEC-2025-218 Hugging Face Transformers GLM4 Deserialization of Untrusted Data Remote Code Execution Vulnerability. | High | Also affects transformers |
| PYSEC-2025-217 Hugging Face Transformers X-CLIP Checkpoint Conversion Deserialization of Untrusted Data Remote Code Execution Vulnerability. | High | Also affects transformers |
| PYSEC-2025-216 Hugging Face Transformers HuBERT convert_config Code Injection Remote Code Execution Vulnerability. | High | Also affects transformers |
MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.
Check your repos with MergeHarbor