Regular Expression Denial of Service (ReDoS) Vulnerability in MooTools Package
Summary
CVE-2021-32821: MooTools is a collection of JavaScript utilities for JavaScript developers. Affects mootools versions < 4501a2979f49156e2375808e1b3cbdb6ecaed849. No fix is published. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
MooTools is a robust collection of JavaScript utilities designed for developers, enabling them to create dynamic web applications with ease. It provides a range of features, including DOM manipulation, event handling, and AJAX capabilities. However, all known versions of MooTools contain a CSS selector parser that is susceptible to a Regular Expression Denial of Service (ReDoS) attack, which can severely impact application performance and availability.
Vulnerability Detail
The vulnerability arises from the CSS selector parser within MooTools, which allows an attacker to inject a malicious string into a CSS selector at runtime. This is particularly concerning as such injections are common in scenarios involving jQuery CSS selectors. The ReDoS attack exploits the way regular expressions are processed, potentially leading to significant delays and resource exhaustion. As a result, applications utilizing MooTools may become unresponsive, affecting user experience and system stability.
How To Fix
No fixed version is published for this vulnerability.
Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →
Workaround
As a temporary workaround, you can implement input validation to restrict the types of strings that can be injected into CSS selectors. This can be done by using a whitelist approach to allow only safe and expected values. For example, you can create a function to validate the input as follows:
function validateCSSSelector(selector) {
const regex = /^[a-zA-Z0-9-_.#]+$/; // Adjust regex as needed
return regex.test(selector);
}
// Usage
if (validateCSSSelector(userInput)) {
// Safe to use the selector
} else {
// Handle invalid input
}
Conclusion
The CVE-2021-32821 vulnerability in MooTools poses a significant risk due to its susceptibility to ReDoS attacks. While there are currently no patches available, developers should take proactive measures to validate input and consider alternative libraries. Utilizing tools like Vulert can help monitor for vulnerabilities in real-time.
See every vulnerability recorded for mootools →
FAQ
ReDoS is a type of attack that exploits the way regular expressions are processed, causing a system to become unresponsive due to excessive resource consumption.
All known versions of MooTools are affected by this vulnerability.
No, there are currently no patches available to fix this vulnerability in MooTools.
You can use the Vulert platform to monitor and alert for open-source vulnerabilities in your software. Visit Vulert Scanner to check if your application is affected.
If upgrading is not an option, implement input validation to sanitize CSS selectors and restrict the types of strings that can be injected.
Related vulnerabilities
Recent vulnerabilities recorded for mootools.