ReDoS Vulnerability in Hugging Face Transformers Library
CVE-2025-5197
What is CVE-2025-5197?
A Regular Expression Denial of Service (ReDoS) vulnerability has been identified in the Hugging Face Transformers library. The issue lies within the convert_tf_weight_name_to_pt_weight_name()
function, which facilitates the conversion of TensorFlow weight names into the PyTorch framework. An exploitable regex pattern /[^/]*___([^/]*)/
can lead to significant CPU resource consumption due to catastrophic backtracking triggered by specifically crafted input strings. This can result in service disruptions, resource exhaustion, and may create potential vulnerabilities in API services, ultimately affecting the efficacy of model conversions between TensorFlow and PyTorch formats. The issue has been patched in version 4.53.0.
Affected Version(s)
huggingface/transformers < 4.53.0