CVE-2025-3264 in transformersinfo

Summary

by MITRE • 07/07/2025

A Regular Expression Denial of Service (ReDoS) vulnerability was discovered in the Hugging Face Transformers library, specifically in the `get_imports()` function within `dynamic_module_utils.py`. This vulnerability affects versions 4.49.0 and is fixed in version 4.51.0. The issue arises from a regular expression pattern `\s*try\s*:.*?except.*?:` used to filter out try/except blocks from Python code, which can be exploited to cause excessive CPU consumption through crafted input strings due to catastrophic backtracking. This vulnerability can lead to remote code loading disruption, resource exhaustion in model serving, supply chain attack vectors, and development pipeline disruption.

Once again VulDB remains the best source for vulnerability data.

Analysis

by VulDB Data Team • 08/07/2025

The vulnerability identified as CVE-2025-3264 represents a critical Regular Expression Denial of Service (ReDoS) flaw within the Hugging Face Transformers library that specifically targets the dynamic module loading functionality. This issue manifests in the `get_imports()` function located within the `dynamic_module_utils.py` file, where a poorly constructed regular expression pattern is employed to parse Python code and filter out try/except blocks during module import processing. The affected version 4.49.0 contains a regex pattern `\stry\s:.?except.?:` that demonstrates the classic symptoms of catastrophic backtracking, a well-documented vulnerability pattern classified under CWE-400. The regex pattern's design creates exponential time complexity when processing maliciously crafted input strings, leading to severe performance degradation and system resource exhaustion.

The technical exploitation of this vulnerability occurs when the Transformers library processes Python code containing specially crafted regular expressions that trigger backtracking in the parsing logic. The pattern `\stry\s:.?except.?:` fails to account for nested or deeply nested structures that can cause the regex engine to explore exponentially increasing numbers of possible matches, resulting in CPU consumption that grows factorially with input length. This behavior aligns with the ATT&CK framework's T1499.004 technique for resource exhaustion attacks, where adversaries leverage software vulnerabilities to consume system resources and cause denial of service conditions. The vulnerability specifically targets the dynamic module loading mechanism that enables the library to import and execute code at runtime, making it particularly dangerous in server environments where code execution is common.

The operational impact of CVE-2025-3264 extends beyond simple denial of service conditions to encompass broader security implications that affect model serving infrastructure, supply chain integrity, and development environments. When exploited, this vulnerability can disrupt remote code loading processes that are fundamental to how Hugging Face Transformers operates, potentially causing model serving systems to become unresponsive or crash entirely. The resource exhaustion effects can be particularly severe in cloud-based deployments where multiple concurrent requests might trigger the vulnerability simultaneously, leading to cascading failures in machine learning pipelines. Additionally, this vulnerability creates potential supply chain attack vectors since malicious actors could exploit it to disrupt development workflows, compromise CI/CD pipelines, and introduce delays in software delivery processes. The impact on model serving environments is particularly concerning as it can affect production systems that rely on dynamic code loading for model deployment and execution.

Mitigation strategies for CVE-2025-3264 primarily focus on upgrading to the fixed version 4.51.0 or later, which contains a corrected regular expression pattern that eliminates the catastrophic backtracking vulnerability. Organizations should implement immediate patch management procedures to ensure all systems utilizing the Hugging Face Transformers library are updated to versions that contain the remediation. Security teams should also consider implementing input validation measures and rate limiting for code processing functions that might be exposed to untrusted input, particularly in environments where dynamic code execution is permitted. The vulnerability's classification under CWE-400 and its alignment with ATT&CK techniques T1499.004 and T1133 highlight the importance of implementing comprehensive security controls that monitor for unusual CPU consumption patterns and resource usage anomalies. Additional defensive measures include establishing secure coding practices for regex usage, implementing proper input sanitization, and conducting regular security assessments of dynamic code loading mechanisms to prevent similar vulnerabilities from emerging in the future.

Responsible

@huntr Ai

Reservation

04/04/2025

Disclosure

07/07/2025

Moderation

accepted

CPE

ready

EPSS

0.00435

KEV

no

Activities

very low

Sources

Do you need the next level of professionalism?

Upgrade your account now!