CVE-2025-6921
transformers: Regular Expression Denial of Service (ReDoS) in huggingface/transformers
Overview
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.
Source: OX vulnerability database
Severity
7.5 · HIGH
CVSS 3.1 base score, scored by NVD.
- Attack vector
- Network
- Attack complexity
- Low
- Privileges required
- None
- User interaction
- None
- Scope
- Unchanged
- Confidentiality
- None
- Integrity
- None
- Availability
- High
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Weakness: CWE-400
Affected packages · 1
| Ecosystem | Package | Vulnerable | Fixed in |
|---|---|---|---|
| PyPI | transformers | <4.53.0 | 4.53.0 |
Open a package to see all its vulnerabilities.
Operating systems · 2 fixes
chainguard 1 release · 1 package
| Release | Package | Fixed in |
|---|---|---|
| text-generation-inference | 3.3.7-r9 |
openSUSE 1 release · 1 package
| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Tumbleweed | python313-transformers +1 | 5.15.0-1.1 | openSUSE-SU-2026:11499-1 |
References
- access.redhat.com https://access.redhat.com/security/cve/CVE-2025-6921
- github.com https://github.com/huggingface/transformers
- github.com https://github.com/huggingface/transformers/commit/47c34fba5c303576560cb29767efb452ff12b8be
- github.com https://github.com/huggingface/transformers/commit/d37f7517972f67e3f2194c000ed0f87f064e5099
- huntr.com https://huntr.com/bounties/287d15a7-6e7c-45d2-8c05-11e305776f1f
- nvd.nist.gov https://nvd.nist.gov/vuln/detail/CVE-2025-6921
- www.cve.org https://www.cve.org/CVERecord?id=CVE-2025-6921
OX Radar and Response Center
Find threats in your stack.
OX Radar can check high-priority threats, like critical package CVEs, against your context.
Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.