Hugging Face Transformers Regular Expression Denial of Service (ReDoS) vulnerability
A regular expression in the Hugging Face Transformers library used for converting TensorFlow weight names to PyTorch format can be made to backtrack excessively by crafted input strings. An attacker could cause high CPU consumption and service disruption during model conversion.
huggingface/transformers
Originally disclosed on huntr
A Regular Expression Denial of Service (ReDoS) vulnerability exists in the Hugging Face Transformers library, specifically in the convert_tf_weight_name_to_pt_weight_name() function. This function, responsible for converting TensorFlow weight names to PyTorch format, uses a regex pattern /[^/]*___([^/]*)/ that can be exploited to cause excessive CPU consumption through crafted input strings due to catastrophic backtracking. The vulnerability affects versions up to 4.51.3 and is fixed in version 4.53.0. This issue can lead to service disruption, resource exhaustion, and potential API service vulnerabilities, impacting model conversion processes between TensorFlow and PyTorch formats.
From the GitHub Advisory Database (GHSA-9356-575x-2w9m, CC BY 4.0).
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the regex pattern used in the weight-name conversion function has nested quantifiers that allow catastrophic backtracking on crafted input.
Impact
This could lead to service disruption, resource exhaustion, and potential API service vulnerabilities, affecting model conversion processes.
What the attacker needed
Ability to supply crafted weight names; model conversion between TensorFlow and PyTorch
The fix
The vulnerability was fixed in version 4.53.0.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A regular expression (regex) is a pattern used to search text. Some patterns can take a very long time to fail on certain inputs, which is called catastrophic backtracking. Here, a function that renames model weights uses such a pattern, so a malicious name could make the program hang and use lots of CPU.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.