Skip to content
OpenAdvisories
Medium · 5.3 CVE-2025-6921 EUVD-2025-30889GHSA-4w7r-h757-3r74PYSEC-2026-1980

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

Published Sep 23, 2025 · Updated Sep 23, 2025 · Assigned by @huntr_ai

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.

Affected products

VendorProductAffectedFixed
huggingface huggingface/transformers unspecified – < 4.53.0 4.53.0

Fixed in Linux distributions

Distributions backport fixes, so the version that fixes this vulnerability differs per release — upgrade to at least the version shown. From the distributions' security trackers and advisories.

ReleasePackageFixed inAdvisory
openSUSE Tumbleweed python-transformers 5.15.0-1.1 openSUSE-SU-2026:11499-1

Affected packages

EcosystemPackageAffectedFixedRecord
PyPI transformers < 4.53.0 4.53.0 GHSA-4w7r-h757-3r74

Advisories 1

References