PyPI: transformers
CVE-2025-3933
Safety vulnerability ID: SFTY-20250711-93122
Safety legacy ID: pyup.io-78153
Affected versions of the `transformers` package are vulnerable to Regular Expression Denial of Service (ReDoS) due to unbounded regular expression complexity. The `DonutProcessor` class's `token2json()` method employs the regex pattern `<s_(.*?)>`, which can be manipulated to trigger catastrophic backtracking with crafted input strings. An attacker can exploit this by providing malicious input to the method, leading to excessive CPU consumption and potential service disruption during document processing tasks.
Overview
Transformers is vulnerable to ReDoS attack through its DonutProcessor class
Advisory
Affected versions of the `transformers` package are vulnerable to Regular Expression Denial of Service (ReDoS) due to unbounded regular expression complexity. The `DonutProcessor` class's `token2json()` method employs the regex pattern `<s_(.*?)>`, which can be manipulated to trigger catastrophic backtracking with crafted input strings. An attacker can exploit this by providing malicious input to the method, leading to excessive CPU consumption and potential service disruption during document processing tasks.
How to Fix
Mitigation and Workarounds
---
Vulnerable Functions
Functions linked to known vulnerabilities.
References
- https://getsafety.com/vulnerabilities/SFTY-20250711-93122/CVE-2025-3933
- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2025-3933
- https://github.com/advisories/GHSA-37mw-44qp-f5jm
- https://huntr.com/bounties/25282953-5827-4384-bb6f-5790d275721b
- https://nvd.nist.gov/vuln/detail/CVE-2025-3933
- https://github.com/huggingface/transformers/commit/ebbe9b12dd75b69f92100d684c47f923ee262a93
- https://huntr.com/bounties/25282953-5827-4384-bb6f-5790d275721b
- https://github.com/huggingface/transformers/pull/37788
- https://github.com/advisories/GHSA-37mw-44qp-f5jm
Verified by Safety
Our Cybersecurity Intelligence Team reviewed this vulnerability. We combine public data with our own research to find issues not yet reported to public sources.
Learn more
