CVE-2025-6921: Transformers Denial of Service Vulnerability
MODERATECVE-2025-6921 is a MODERATE (CVSS 5.3) denial of service vulnerability (CWE-400: Uncontrolled Resource Consumption) affecting Transformers libraries in the PyPI ecosystem. The issue involves hugging face transformers vulnerable to regular expression denial of service (redos) in the adamweightdecay optimizer. Remediation is available by upgrading affected packages to version 4.53.0.
CVE-2025-6921 at a Glance
Security Impact
CVSS: 5.3
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L).
How to Fix CVE-2025-6921
To remediate this vulnerability, upgrade all affected Transformers dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install transformers>=4.53.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show transformers
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2025-6921, inspect your installed packages using pip:
pip show transformers
Analyze the terminal output to locate any version of Transformers in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.53.0), your application is affected.
Note: The pip show transformers command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-400: Uncontrolled Resource Consumption, where the product does not properly control the allocation and maintenance of a limited resource. In Transformers, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2025-6921 Affected Transformers Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
transformers
|
PyPI |
< 4.53.0
|
4.53.0
|
References
Frequently Asked Questions
What is CVE-2025-6921?
Which Transformers versions are affected?
What version fixes CVE-2025-6921?
Is transformers affected?
What is the CVSS score of CVE-2025-6921?
What CWE is associated with CVE-2025-6921?
How can I check PyPI dependencies for CVE-2025-6921?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-4w7r-h757-3r74",
"modified" : "2025-09-23T17:37:49Z",
"published" : "2025-09-23T15:31:09Z",
"aliases" : [ "CVE-2025-6921" ],
"summary" : "Hugging Face Transformers vulnerable to Regular Expression Denial of Service (ReDoS) in the AdamWeightDecay optimizer",
"details" : "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.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "transformers"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "4.53.0"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-6921"
}, {
"type" : "WEB",
"url" : "https://github.com/huggingface/transformers/commit/47c34fba5c303576560cb29767efb452ff12b8be"
}, {
"type" : "WEB",
"url" : "https://github.com/huggingface/transformers/commit/d37f7517972f67e3f2194c000ed0f87f064e5099"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/huggingface/transformers"
}, {
"type" : "WEB",
"url" : "https://huntr.com/bounties/287d15a7-6e7c-45d2-8c05-11e305776f1f"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-400" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2025-09-23T17:37:49Z",
"nvd_published_at" : "2025-09-23T14:15:41Z"
}
}