CVE-2025-3933: Transformers Library Vulnerable to ReDoS Attack via DonutProcessor Class
Summary
CVE-2025-3933: Transformers is vulnerable to ReDoS attack through its DonutProcessor class. Affects transformers versions < 4.52.1. Fixed in 4.52.1. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
The Transformers library, developed by Hugging Face, is a widely used open-source library for natural language processing tasks. It provides various pre-trained models and tools for tasks such as text generation, translation, and document processing. The library's DonutProcessor class is specifically designed for processing documents using the Donut model. However, it has been found to be vulnerable to a Regular Expression Denial of Service (ReDoS) attack, which can severely impact its performance and availability.
Vulnerability Detail
A Regular Expression Denial of Service (ReDoS) vulnerability exists in the DonutProcessor class's token2json() method of the Transformers library. This vulnerability affects versions 4.51.3 and earlier and is caused by the regex pattern <s_(.*?)>. Attackers can exploit this vulnerability by providing crafted input strings that lead to catastrophic backtracking, resulting in excessive CPU consumption. The consequences include service disruption, resource exhaustion, and potential vulnerabilities in API services, particularly affecting document processing tasks.
How To Fix
Latest published version: 5.20.2 as of 22 Oct 2026
pip install --upgrade "transformers==5.20.2"
Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.
If you need the minimum change
4.52.1
This is the first release that contains the fix.
pip install --upgrade "transformers==4.52.1"
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
As a temporary workaround, avoid using the DonutProcessor class for processing documents until the library is updated. Additionally, consider validating input strings to prevent crafted inputs that could trigger the vulnerability.
Conclusion
The CVE-2025-3933 vulnerability in the Transformers library poses a significant risk due to its potential for causing ReDoS attacks. Users are advised to update to version 4.52.1 or later to mitigate this risk. Regular monitoring and prompt updates are essential to maintain the security of applications using this library.
See every vulnerability recorded for transformers →
FAQ
A ReDoS attack exploits vulnerabilities in regular expressions to cause excessive CPU usage, leading to service disruption.
Versions 4.51.3 and earlier of the Transformers library are affected by this vulnerability.
You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without any signup.
The vulnerability can lead to service disruption, resource exhaustion, and potential API service vulnerabilities, particularly in document processing tasks.
Yes, the vulnerability is fixed in version 4.52.1 of the Transformers library. Updating to this version will resolve the issue.
References
Related vulnerabilities
Recent vulnerabilities recorded for transformers.