AgentbeamBeta
AI agent vulnerability · Transformers

CVE-2025-3933: Transformers is vulnerable to ReDoS attack through its DonutProcessor class

mediumCVSS 3.1 5.3GHSA-37mw-44qp-f5jm

Hugging Face Transformers 4.51.3 and earlier has a regular-expression denial of service in the DonutProcessor class. Crafted model output can make the parser burn CPU and stall the process. The fix is in 4.52.1.

Published Jul 11, 2025 · Updated Aug 7, 2025 · Analysis Nov 10, 2026

What an attacker can do

The Donut processor, in src/transformers/models/donut/processing_donut.py, turns model output tokens into structured data with a regular expression. The fix pull request describes it as an exploitable regex and replaces it with less blowup-prone code, a plain search for the closing marker over a slice of the token string. The sources we read do not show the original pattern or the exact input that triggers the blowup.

The effect is a ReDoS. A crafted string makes the regex take very long, which ties up a CPU core. An attacker needs to get that string into the processor, for example through a document or generation output that your service passes to DonutProcessor. A service that runs Donut on untrusted input can be stalled this way. It does not give code execution or data access.

Who is affected

The pip package transformers, versions 4.51.3 and earlier, in code that uses DonutProcessor. Check:

pip show transformers

Search your code for DonutProcessor to see whether the vulnerable class is in use.

transformers

Ecosystem
PyPI
Affected
<= 4.51.3
Fixed in
4.52.1
Check
pip show transformers

How to fix it

Upgrade to 4.52.1:

pip install --upgrade transformers==4.52.1

The fix is pull request 37788, which replaces the regex in the Donut processor. The sources list no workaround. If you cannot upgrade, avoid passing untrusted input through DonutProcessor and set time limits on requests that use it.

How to tell if you were hit

Look for worker processes pinned at high CPU inside Donut parsing code, request timeouts on endpoints that call DonutProcessor, and Python stack traces ending in the re module in processing_donut.py. The sources name no log line for this.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

A Regular Expression Denial of Service (ReDoS) vulnerability was discovered in the Hugging Face Transformers library, specifically within the DonutProcessor class's token2json() method. This vulnerability affects versions 4.51.3 and earlier, and is fixed in version 4.52.1. The issue arises from the regex pattern <s_(.*?)> which can be exploited to cause excessive CPU consumption through crafted input strings due to catastrophic backtracking. This vulnerability can lead to service disruption, resource exhaustion, and potential API service vulnerabilities, impacting document processing tasks using the Donut model.

Questions

Which Transformers version fixes CVE-2025-3933?

4.52.1. Versions up to 4.51.3 are affected.

Does this allow code execution?

No. It is a regular-expression denial of service. Crafted input makes the processor consume CPU and stall.

Am I affected if I do not use Donut models?

The flaw is in the DonutProcessor class. Code that never uses it does not reach the vulnerable regex. Upgrading is still advisable.

Is a workaround documented?

No. Upgrade, or keep untrusted input away from DonutProcessor and put timeouts on those requests.

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