GHSA-jjph-296x-mrcr CVE-2025-3264 PYSEC-2026-1985
Transformers vulnerable to ReDoS attack through its get_imports() function
- Severity
- 5.3 / 10
- Medium · CVSS 3.0
- Exploit chance (EPSS)
- 0.50%
- Chance of exploitation in the next 30 days. Higher than 42.56% of scored vulnerabilities.
- Known exploited
- No
- Not in CISA's catalog
- Weakness
- CWE-1333 Inefficient Regular Expression Complexity
- Fix
4.51.0- Upgrade transformers to this version or later
Description
A Regular Expression Denial of Service (ReDoS) vulnerability was discovered in the Hugging Face Transformers library, specifically in the get_imports() function within dynamic_module_utils.py. This vulnerability affects versions 4.49.0 and is fixed in version 4.51.0. The issue arises from a regular expression pattern \s*try\s*:.*?except.*?: used to filter out try/except blocks from Python code, which can be exploited to cause excessive CPU consumption through crafted input strings due to catastrophic backtracking. This vulnerability can lead to remote code loading disruption, resource exhaustion in model serving, supply chain attack vectors, and development pipeline disruption.
Affected versions
PyPI
| Package | Vulnerable | Fixed in |
|---|---|---|
| transformers | < 4.51.0 |
4.51.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.51.0
- pip
pip install --upgrade "transformers>=4.51.0"- poetry
poetry add "transformers>=4.51.0"- uv
uv add "transformers>=4.51.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