CVE-2022-31147 Overview
The jQuery Validation Plugin (jquery-validation) provides drop-in validation for forms and is widely used across web applications. Versions prior to 1.19.5 are vulnerable to Regular Expression Denial of Service (ReDoS) when an attacker is able to supply arbitrary input to the url2 method. This vulnerability represents an incomplete fix for CVE-2021-43306, indicating that the original remediation did not fully address the underlying regular expression complexity issue.
Critical Impact
Attackers can cause application denial of service by supplying crafted input strings to the url2 validation method, causing catastrophic backtracking in the regular expression engine and exhausting server resources.
Affected Products
- jQuery Validation Plugin versions prior to 1.19.5
- jqueryvalidation jquery_validation for Node.js
- Web applications utilizing the vulnerable url2 validation method
Discovery Timeline
- July 14, 2022 - CVE-2022-31147 published to NVD
- November 21, 2024 - Last updated in NVD database
Technical Details for CVE-2022-31147
Vulnerability Analysis
This vulnerability is classified as CWE-1333 (Inefficient Regular Expression Complexity), commonly known as ReDoS (Regular Expression Denial of Service). The url2 method in the jQuery Validation Plugin uses a complex regular expression for URL validation that contains patterns susceptible to catastrophic backtracking when processing specially crafted input strings.
When a regular expression contains nested quantifiers or overlapping alternations, certain input patterns can cause the regex engine to explore an exponentially growing number of matching paths. This computational explosion can freeze the JavaScript event loop, rendering the application unresponsive to legitimate requests. Since this vulnerability can be triggered remotely through form input, it poses a significant availability risk to web applications relying on this validation method.
Root Cause
The root cause lies in the inefficient regular expression pattern used within the url2 validation method. The original fix for CVE-2021-43306 did not adequately address all backtracking scenarios in the URL validation regex. The pattern contained segments that could match overlapping character sequences, particularly in the username/password portion of URLs, leading to exponential time complexity when processing malicious input.
Attack Vector
The attack can be executed remotely over the network without authentication. An attacker needs to identify a form field validated using the url2 method and submit a specially crafted string designed to trigger catastrophic backtracking. This causes the server or client-side JavaScript to become unresponsive while the regex engine attempts to process the malicious input. The attack requires no privileges and no user interaction beyond the victim's application being accessible.
// Vulnerable regex pattern in url2 method (before patch)
// Source: https://github.com/jquery-validation/jquery-validation/commit/5bbd80d27fc6b607d2f7f106c89522051a9fb0dd
// The vulnerable pattern used \S+ for matching userinfo which allowed catastrophic backtracking
return this.optional( element ) || /^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\\u00a1-\\uffff][a-z0-9\\u00a1-\\uffff_-]{0,62})?[a-z0-9\\u00a1-\\uffff]\.?)+(?:[a-z\\u00a1-\\uffff]{2,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?$/i.test( value );
Source: GitHub Commit 5bbd80d
Detection Methods for CVE-2022-31147
Indicators of Compromise
- Unusually high CPU utilization on web servers or client browsers processing form submissions
- Slow or unresponsive form validation operations, particularly on URL input fields
- Server logs showing extended request processing times for form submissions
- Client-side JavaScript execution timeouts or browser tab freezes during form validation
Detection Strategies
- Implement software composition analysis (SCA) to identify jQuery Validation Plugin versions prior to 1.19.5
- Monitor application performance metrics for anomalous spikes during form processing operations
- Review JavaScript bundle dependencies using npm audit or similar dependency scanning tools
- Analyze web application firewall (WAF) logs for unusual patterns in URL-formatted form inputs
Monitoring Recommendations
- Deploy application performance monitoring (APM) to track JavaScript execution times and identify potential ReDoS attacks
- Configure alerting for elevated server CPU usage correlated with form submission endpoints
- Implement client-side error tracking to capture validation timeout events
- Establish baseline metrics for form validation response times to identify anomalous behavior
How to Mitigate CVE-2022-31147
Immediate Actions Required
- Upgrade jQuery Validation Plugin to version 1.19.5 or later immediately
- Audit all web applications using jquery-validation to inventory affected deployments
- Implement server-side validation as a defense-in-depth measure rather than relying solely on client-side validation
- Consider implementing request timeouts and rate limiting on form submission endpoints
Patch Information
The vendor has released version 1.19.5 which contains the complete fix for this vulnerability. The patch modifies the regular expression in both src/additional/url2.js and src/core.js to use a more efficient pattern that avoids catastrophic backtracking. The fix replaces the vulnerable \S+ pattern with a more restrictive character class that explicitly defines allowed characters.
For detailed patch information, see the GitHub Security Advisory GHSA-ffmh-x56j-9rc3 and the version 1.19.5 release.
Workarounds
- Disable the url2 validation method if not required and use alternative URL validation approaches
- Implement input length restrictions on URL fields to limit the potential for ReDoS exploitation
- Add server-side URL validation using well-tested libraries that are not vulnerable to ReDoS
- Consider using a web application firewall (WAF) rule to filter potentially malicious URL patterns
# Update jQuery Validation Plugin via npm
npm update jquery-validation@1.19.5
# Verify installed version
npm list jquery-validation
# Alternative: Update via package.json
# Set minimum version: "jquery-validation": ">=1.19.5"
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.


