Skip to content
DoS Disclosed report Intermediate CVE-2025-2099

Hugging Face Transformers Regular Expression Denial of Service

A regular expression in the preprocess_string() function of the transformers.testing_utils module used nested quantifiers that could cause catastrophic backtracking when given inputs with many newline characters. An attacker who can supply such input could force excessive CPU usage and degrade availability.

huggingface/transformers

Originally disclosed on huntr

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

From the GitHub Advisory Database (GHSA-qq3j-4f4f-9583, CC BY 4.0).

The original report as published on the GitHub Advisory Database. Images and videos are our own copies; raw HTML is shown as text. View it on GitHub Advisory Database.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the regular expression used nested quantifiers, which can lead to catastrophic backtracking on inputs with many newline characters.

Impact

An attacker who can supply such input could force excessive CPU usage and degrade availability.

What the attacker needed

Ability to supply input to preprocess_string()

The fix

It was fixed in version 4.50.0 by rewriting the regex to avoid the inefficient pattern.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A regular expression is a pattern used to search text. Some patterns can become extremely slow when they try to match certain inputs, using up all the computer's processing power. Here, a badly written pattern could be fed a string with many newlines, making the program hang and become unavailable to others.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More from huggingface/transformers

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.