CVE-2025-3933: Transformers is vulnerable to ReDoS attack through its DonutProcessor class
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 transformersSearch 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.1The 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
Read for this analysis:
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 entriesCVE-2026-80047
Hugging Face Transformers downloads custom generation code before trust consent
high7.8No fixSep 1, 2026CVE-2026-9856
Transformers save_pretrained path traversal allows arbitrary file writes through chat template names
high7.1Aug 2, 2026CVE-2026-5241
huggingface/transformers: Arbitrary Code Execution During Model Initialization in the LightGlue Model Loading Path
high8.0Jun 3, 2026CVE-2026-4372
HuggingFace transformers vulnerable to remote code execution
high7.8May 26, 2026CVE-2026-1839
HuggingFace Transformers allows for arbitrary code execution in the `Trainer` class
medium6.5Apr 7, 2026CVE-2025-6921
Hugging Face Transformers vulnerable to Regular Expression Denial of Service (ReDoS) in the AdamWeightDecay optimizer
medium5.3Sep 23, 2025
