NewApp Monitoring is liveSign up free
AgentbeamBeta
AI agent vulnerability · Transformers

CVE-2025-3262: Transformers vulnerable to ReDoS attack through its SETTING_RE variable

mediumCVSS 3.1 5.3GHSA-489j-g2vx-39wf

Hugging Face Transformers 4.49.0 up to 4.50.x has a regular expression denial of service in the SETTING_RE pattern in transformers/commands/chat.py. A crafted almost-matching string makes the regex backtrack heavily and burn CPU. Only the chat command is involved. Upgrade to transformers 4.51.0.

Published Jul 7, 2025 · Updated Aug 4, 2025 · Analysis Nov 1, 2026

What an attacker can do

The transformers chat command accepts set key=value commands, including several pairs separated by semicolons. The SETTING_RE pattern, which began with ^set\s+[A-Za-z\s_]+=, used repeated groups and non-optimized quantifiers. The advisory says input that almost matches causes exponential backtracking, which degrades performance and can lead to denial of service.

The attacker must get a crafted string into that chat command's input. That fits a narrow case: a service or terminal session that exposes the chat command to untrusted users. Most applications that import the Transformers library never run this code, so exposure is small. The CVSS vector scores network access with no privileges and low availability impact only. There is no data exposure or code execution.

The effect is one process stuck on CPU. A shared inference host running the chat command for several users could see slow responses for everyone until the process is killed.

Who is affected

The package data lists transformers from 4.49.0 up to but not including 4.51.0. The advisory names 4.49.0 as the version where the issue was found. You are exposed only if you run the transformers chat command, or code that wraps it, on input from people you do not trust.

pip show transformers

Check images and virtual environments separately, as they often pin different versions.

transformers

Ecosystem
PyPI
Affected
>= 4.49.0, < 4.51.0
Fixed in
4.51.0
Check
pip show transformers

How to fix it

Upgrade to transformers 4.51.0.

pip install --upgrade "transformers>=4.51.0"

The fix commit, 126abe3, removes SETTING_RE and adds a static method, is_valid_setting_command, in chat.py. It requires input to start with set and contain an equals sign, splits on semicolons, needs exactly one equals sign per assignment, rejects empty keys and values, and checks keys and values against allowed character sets. No regex runs on the input. The sources give no other workaround. If you cannot upgrade, do not expose the chat command to untrusted input.

How to tell if you were hit

Look for a transformers chat process pinned at high CPU with input that begins with set and contains long runs of letters, spaces or underscores that never reach a valid equals sign. A stack dump of a stuck process shows frames in the re module called from chat.py. Check version pins in every environment that ships transformers, and whether anything exposes the chat command beyond your own terminal.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

A Regular Expression Denial of Service (ReDoS) vulnerability was discovered in the huggingface/transformers repository, specifically in version 4.49.0. The vulnerability is due to inefficient regular expression complexity in the SETTING_RE variable within the transformers/commands/chat.py file. The regex contains repetition groups and non-optimized quantifiers, leading to exponential backtracking when processing 'almost matching' payloads. This can degrade application performance and potentially result in a denial-of-service (DoS) when handling specially crafted input strings. The issue is fixed in version 4.51.0.

Questions

Does CVE-2025-3262 affect every use of Transformers?

No. The flaw is in the regex used by the chat command in transformers/commands/chat.py. Code that only loads models or runs pipelines does not use that pattern.

Which version fixes it?

transformers 4.51.0. The affected range in the package data is 4.49.0 up to 4.51.0.

What is the worst outcome?

Denial of service. The CVSS vector shows low availability impact and no confidentiality or integrity impact. A crafted input ties up CPU in the affected process.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology

More Transformers vulnerabilities

All Transformers entries