Skip to content
Heist/ feed
Back to feed
Medium

Regular Expression Denial of Service (ReDoS) in huggingface/transformers

Type: advisorySources: OSV

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.

Products
Not specified
Affected versions
Not specified
Fixed versions
Not specified
CVEs
CVE-2025-6921
Confirmed fixed CVEs
Not specified
Updated in this feed
3 Nov 2026, 03:59 UTC · Revision 1

Source evidence

Regular Expression Denial of Service (ReDoS) in huggingface/transformers

core-osv · Original source

Published 23 Sept 2025, 13:56 UTC

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.

osv:CVE-2025-6921
Complete source record
{
  "id": "fbf34c1f6afafbdf86077c14ec9dbb1fc4dab4fc8cad7328b4fd15fad0618cbc",
  "url": "https://osv.dev/vulnerability/CVE-2025-6921",
  "method": "structured",
  "payload": {
    "kind": "advisory",
    "title": "Regular Expression Denial of Service (ReDoS) in huggingface/transformers",
    "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. 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.",
    "evidence": "osv:CVE-2025-6921",
    "products": [],
    "severity": "medium",
    "structured": {
      "id": "CVE-2025-6921",
      "aliases": [
        "CVE-2025-6921",
        "GHSA-4w7r-h757-3r74",
        "PYSEC-2026-1980"
      ],
      "metrics": [
        {
          "type": "CVSS_V3",
          "score": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L"
        }
      ],
      "affected": [
        {
          "ranges": [
            {
              "repo": "https://github.com/huggingface/transformers",
              "type": "GIT",
              "events": [
                {
                  "introduced": "0"
                },
                {
                  "fixed": "67ddc82fbc7e52c6f42a395b4a6d278c55b77a39"
                },
                {
                  "fixed": "47c34fba5c303576560cb29767efb452ff12b8be"
                }
              ],
              "database_specific": {
                "extracted_events": [
                  {
                    "cpe": "cpe:2.3:a:huggingface:transformers:*:*:*:*:*:*:*:*",
                    "range": [
                      {
                        "introduced": "0"
                      },
                      {
                        "fixed": "4.53.0"
                      }
                    ],
                    "source": "CPE_RANGE"
                  },
                  {
                    "range": [
                      {
                        "fixed": "47c34fba5c303576560cb29767efb452ff12b8be"
                      }
                    ],
                    "source": "REFERENCES_COMMIT"
                  }
                ]
              }
            }
          ],
          "versions": [
            "v4.52.4-Kyutai-STT-preview",
            "v4.52.4-VJEPA-2-preview",
            "v4.52.4-ColQwen2-preview",
            "v4.51.3-CSM-preview",
            "v4.51.3-GraniteMoeHybrid-preview",
            "v4.51.3-LlamaGuard-preview",
            "v4.51.3-D-FINE-preview",
            "v4.51.3-SAM-HQ-preview",
            "v4.51.3-BitNet-preview",
            "v4.51.3-InternVL-preview",
            "v4.51.3-Janus-preview",
            "v4.51.3-TimesFM-preview",
            "v4.51.3-MLCD-preview",
            "v4.51.3-Qwen2.5-Omni-preview",
            "v4.50.3-DeepSeek-3",
            "v4.49.0-Mistral-3",
            "v4.49.0-AyaVision",
            "v4.49.0-SigLIP-2",
            "v4.49.0-SmolVLM-2",
            "v4.33.1",
            "v4.16.0",
            "v4.15.0",
            "v4.14.0",
            "v4.13.0",
            "v4.12.0",
            "v4.11.0",
            "v4.10.0",
            "v4.9.0",
            "v4.8.0",
            "v4.7.0",
            "v4.6.0",
            "v4.5.0",
            "v4.4.0",
            "v4.3.0.rc1",
            "4.3.0.rc1",
            "v4.2.0",
            "v4.1.1",
            "v4.1.0",
            "v3.5.0",
            "v3.4.0",
            "v3.3.1",
            "v3.3.0",
            "v3.2.0",
            "v3.1.0",
            "v3.0.2",
            "v3.0.1",
            "3.0.1",
            "v3.0.0",
            "v2.11.0",
            "v2.10.0",
            "v2.9.1",
            "v2.9.0",
            "v2.8.0",
            "v2.7.0",
            "v2.6.0",
            "v2.5.1",
            "v2.5.0",
            "v2.4.1",
            "v2.4.0",
            "v2.3.0",
            "v2.2.2",
            "v2.2.1",
            "v2.2.0",
            "v2.1.1",
            "v2.1.0",
            "v2.0.0",
            "1.2.0",
            "1.1.0",
            "1.0",
            "v0.6.2",
            "v0.6.1",
            "v0.6.0",
            "v0.5.1",
            "v0.5.0",
            "0.5.0",
            "v0.4.0",
            "v0.3.0",
            "v0.2.0",
            "v0.1.2",
            "0.1.2"
          ],
          "database_specific": {
            "source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2025-6921.json"
          }
        }
      ],
      "modified": "2026-10-28T02:30:25.931791389Z",
      "provider": "osv",
      "references": [
        "https://huntr.com/bounties/287d15a7-6e7c-45d2-8c05-11e305776f1f",
        "https://github.com/CVEProject/cvelistV5/tree/main/cves/2025/6xxx/CVE-2025-6921.json",
        "https://nvd.nist.gov/vuln/detail/CVE-2025-6921",
        "https://github.com/huggingface/transformers/commit/47c34fba5c303576560cb29767efb452ff12b8be"
      ],
      "provider_metadata": {
        "cwe_ids": [
          "CWE-400"
        ],
        "cna_assigner": "@huntr_ai",
        "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2025/6xxx/CVE-2025-6921.json"
      }
    },
    "related_cves": [
      {
        "value": "CVE-2025-6921",
        "evidence": "/id"
      }
    ],
    "security_relevant": true,
    "severity_evidence": "/severity/0/score"
  },
  "source_id": "core-osv",
  "document_id": 492339,
  "published_at": "2025-09-23T13:56:15.636+00:00"
}