Skip to main content

Inefficient Regular Expression Complexity

CVE-2025-6921

Severity High
Score 7.5/10

Summary

The huggingface/transformers library, versions prior to 4.53.0, is vulnerable to Regular Expression Denial-of-Service (ReDoS) in the "AdamWeightDecay" optimizer. The vulnerability arises from the "_do_use_weight_decay()" method, which processes user-controlled regular expressions in the "include_in_weight_decay" and "exclude_from_weight_decay" lists. Malicious regular expressions can cause catastrophic backtracking during the "re.search" call, leading to 100% CPU utilization and a Denial-of-Service(DoS). This issue can be exploited by attackers who can control the patterns in these lists, potentially causing the machine learning task to hang and rendering services unresponsive.

  • LOW
  • NETWORK
  • NONE
  • UNCHANGED
  • NONE
  • NONE
  • NONE
  • HIGH

CWE-1333 - Inefficient Regular Expression Complexity

The product uses a regular expression with an inefficient, possibly exponential worst-case computational complexity that consumes excessive CPU cycles.

Advisory Timeline

  • Published