Executive brief
Hugging Face Transformers is a widely-used machine learning library for natural language processing and document understanding. The DonutProcessor class contains a Regular Expression Denial of Service (ReDoS) vulnerability that can be triggered by specially crafted input strings, causing excessive CPU consumption and potential service disruption when processing documents with the Donut model.
Technical details
A Regular Expression Denial of Service (ReDoS) vulnerability exists in the DonutProcessor class's token2json() method, triggered by the regex pattern <s_(.*?)> which is vulnerable to catastrophic backtracking. The vulnerability affects all versions up to and including 4.51.3, with a fix available in version 4.52.1. An attacker can craft malicious input strings to cause excessive CPU consumption, leading to service disruption and resource exhaustion, particularly impacting API services and document processing tasks. The vulnerability is triggered through network input if the affected service processes user-supplied documents, and no authentication is typically required to exploit it. A patch is available and should be applied immediately by upgrading to version 4.52.1 or later.
Affected products
- Hugging Face Transformers <=4.51.3
Timeline
- 2025-07-11: disclosed
- 2025-05-06: patched: Fix merged in PR #37788; version 4.52.1 contains the patch