Skip to content

GHSA-37mw-44qp-f5jm CVE-2025-3933 PYSEC-2026-1977

Transformers is vulnerable to ReDoS attack through its DonutProcessor class

Medium PyPI
Severity
5.3 / 10
Medium · CVSS 3.1
Exploit chance (EPSS)
0.50%
Chance of exploitation in the next 30 days. Higher than 42.56% of scored vulnerabilities.
Known exploited
No
Not in CISA's catalog
Weakness
CWE-1333 Inefficient Regular Expression Complexity
Fix
4.52.1
Upgrade transformers to this version or later

Description

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.

Affected versions

PyPI

PackageVulnerableFixed in
transformers
< 4.52.1
4.52.1

How to fix

Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.

transformers PyPI → 4.52.1

pip
pip install --upgrade "transformers>=4.52.1"
poetry
poetry add "transformers>=4.52.1"
uv
uv add "transformers>=4.52.1"

Severity breakdown

CVSS 3.1 5.3

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
None
Availability
Low

Weakness

CWE-1333: Inefficient Regular Expression Complexity

The product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential.

How to prevent it
  • Architecture and Design: Use regular expressions that do not support backtracking, e.g. by removing nested quantifiers.
  • System Configuration: Set backtracking limits in the configuration of the regular expression implementation, such as PHP's pcre.backtrack_limit. Also consider limits on execution time for the process.
  • Implementation: Do not use regular expressions with untrusted input. If regular expressions must be used, avoid using backtracking in the expression.
  • Implementation: Limit the length of the input that the regular expression will process.

References

Timeline

  1. Published
  2. Last updated by the source
  3. Latest EPSS score
AdvisorySeverityWhy it's related
GHSA-x9r9-c232-4q39
Hugging Face Transformers downloads custom generation code before trust consent
High Also affects transformers
GHSA-xrqw-3rrv-vx5w
Transformers save_pretrained path traversal allows arbitrary file writes through chat template names
High Also affects transformers
GHSA-fgcw-684q-jj6r
huggingface/transformers: Arbitrary Code Execution During Model Initialization in the LightGlue Model Loading Path
Critical Also affects transformers
GHSA-29pf-2h5f-8g72
HuggingFace transformers vulnerable to remote code execution
High Also affects transformers
GHSA-69w3-r845-3855
HuggingFace Transformers allows for arbitrary code execution in the `Trainer` class
High Also affects transformers
PYSEC-2025-218
Hugging Face Transformers GLM4 Deserialization of Untrusted Data Remote Code Execution Vulnerability.
High Also affects transformers
PYSEC-2025-217
Hugging Face Transformers X-CLIP Checkpoint Conversion Deserialization of Untrusted Data Remote Code Execution Vulnerability.
High Also affects transformers
PYSEC-2025-216
Hugging Face Transformers HuBERT convert_config Code Injection Remote Code Execution Vulnerability.
High Also affects transformers
Is this in your code?

MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.

Check your repos with MergeHarbor