Hugging Face Transformers is vulnerable to ReDoS through its MarianTokenizer
The MarianTokenizer's remove_language_code() method used an inefficient regular expression that could be exploited with crafted input strings containing malformed language code patterns, causing excessive CPU consumption and denial of service. The vulnerability was present in version 4.52.4 and fixed in 4.53.0.
huggingface/transformers
Originally disclosed on huntr
A Regular Expression Denial of Service (ReDoS) vulnerability was discovered in the Hugging Face Transformers library, specifically affecting the MarianTokenizer's remove_language_code() method. This vulnerability is present in version 4.52.4 and has been fixed in version 4.53.0. The issue arises from inefficient regex processing, which can be exploited by crafted input strings containing malformed language code patterns, leading to excessive CPU consumption and potential denial of service.
From the GitHub Advisory Database (GHSA-59p9-h35m-wg4g, 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 in remove_language_code() had catastrophic backtracking when matching malformed language code patterns.
Impact
An attacker could cause excessive CPU consumption, potentially leading to denial of service.
What the attacker needed
Crafted input string with malformed language code patterns
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 is a pattern used to search or manipulate text. If that pattern is written inefficiently, certain inputs can make the computer take a very long time to process it, which is called a denial of service because the service becomes too busy to respond to normal requests. Here, a specific text tokenizer in a machine-learning library had such a pattern, so a malicious input could slow it down.
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.