Skip to main content

CVE-2025-6921: CWE-400 Uncontrolled Resource Consumption in huggingface huggingface/transformers

Medium
VulnerabilityCVE-2025-6921cvecve-2025-6921cwe-400
Published: Tue Sep 23 2025 (09/23/2025, 13:56:15 UTC)
Source: CVE Database V5
Vendor/Project: huggingface
Product: huggingface/transformers

Description

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. 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.

AI-Powered Analysis

AILast updated: 09/23/2025, 14:02:31 UTC

Technical Analysis

CVE-2025-6921 is a vulnerability classified under CWE-400 (Uncontrolled Resource Consumption) affecting the huggingface/transformers library versions prior to 4.53.0. The issue is a Regular Expression Denial of Service (ReDoS) vulnerability located in the AdamWeightDecay optimizer component, specifically within the _do_use_weight_decay method. This method processes user-controlled regular expressions provided in the include_in_weight_decay and exclude_from_weight_decay lists. An attacker who can supply maliciously crafted regular expressions can trigger catastrophic backtracking during the execution of Python's re.search function. This results in excessive CPU consumption, potentially maxing out processor usage and causing the machine learning task or service relying on this library to hang or become unresponsive. The vulnerability does not impact confidentiality or integrity but affects availability by causing denial of service. Exploitation does not require authentication or user interaction, and the attack can be launched remotely if the attacker can influence the regular expression inputs. The CVSS v3.0 score is 5.3 (medium severity), reflecting the network attack vector, low complexity, no privileges required, no user interaction, and impact limited to availability. No known exploits are currently reported in the wild, and no official patches are linked yet, though upgrading to version 4.53.0 or later is implied to remediate the issue.

Potential Impact

For European organizations, the impact of this vulnerability can be significant in environments where huggingface/transformers is used for machine learning workflows, especially those involving the AdamWeightDecay optimizer with configurable weight decay patterns. Organizations in sectors such as finance, healthcare, research, and technology that rely on AI/ML models for critical decision-making or service delivery could experience service disruptions or degraded performance. The denial of service caused by CPU exhaustion can lead to downtime, delayed processing, and potential cascading effects on dependent systems or services. Since the vulnerability can be triggered remotely without authentication, exposed APIs or services that accept user input influencing these regular expressions are at risk. This could affect cloud-based ML platforms, AI-driven applications, or internal ML pipelines. While the vulnerability does not lead to data breaches or integrity compromise, the availability impact can affect business continuity and operational efficiency.

Mitigation Recommendations

European organizations should take the following specific mitigation steps: 1) Immediately audit usage of the huggingface/transformers library, focusing on versions prior to 4.53.0 and the use of AdamWeightDecay optimizer with user-configurable include_in_weight_decay or exclude_from_weight_decay parameters. 2) Restrict or sanitize inputs that influence these regular expression lists to prevent malicious patterns from being processed. Implement strict validation or whitelist acceptable regex patterns. 3) Upgrade the huggingface/transformers library to version 4.53.0 or later once available, as this version addresses the vulnerability. 4) Monitor CPU utilization and application logs for signs of excessive resource consumption or hanging processes related to ML tasks. 5) Isolate ML workloads in controlled environments with resource limits (e.g., CPU quotas, container limits) to mitigate impact if exploitation occurs. 6) For exposed services accepting user input that could influence these regex parameters, implement network-level protections such as WAF rules to detect and block suspicious payloads. 7) Educate developers and data scientists about the risks of processing untrusted regular expressions and encourage secure coding practices around regex usage.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.1
Assigner Short Name
@huntr_ai
Date Reserved
2025-06-30T09:44:12.092Z
Cvss Version
3.0
State
PUBLISHED

Threat ID: 68d2a78d3a159a196863e81d

Added to database: 9/23/2025, 1:58:37 PM

Last enriched: 9/23/2025, 2:02:31 PM

Last updated: 9/25/2025, 12:08:24 AM

Views: 10

Actions

PRO

Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.

Please log in to the Console to use AI analysis features.

Need enhanced features?

Contact root@offseq.com for Pro access with improved analysis and higher rate limits.

Latest Threats