Transformers vulnerable to ReDoS attack through its get_imports() function
A regular expression in the get_imports() function of the Hugging Face Transformers library could be made to backtrack catastrophically by crafted input, causing excessive CPU consumption. An attacker could disrupt remote code loading, exhaust resources in model serving, and interfere with development pipelines.
huggingface/transformers
Originally disclosed on huntr
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.
From the GitHub Advisory Database (GHSA-jjph-296x-mrcr, 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 regular expression pattern used to filter try/except blocks is not efficient and allows catastrophic backtracking on crafted input.
Impact
An attacker could cause excessive CPU consumption, leading to remote code loading disruption, resource exhaustion in model serving, supply chain attack vectors, and development pipeline disruption.
What the attacker needed
Crafted input string
The fix
The vulnerability was fixed in version 4.51.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 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 pattern meant to remove try/except blocks from Python code could be fed a string that makes it work extremely hard, slowing down or freezing the program that uses the library.
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.