CVE-2022-31129: CWE-400: Uncontrolled Resource Consumption in moment moment
moment is a JavaScript date library for parsing, validating, manipulating, and formatting dates. Affected versions of moment were found to use an inefficient parsing algorithm. Specifically using string-to-date parsing in moment (more specifically rfc2822 parsing, which is tried by default) has quadratic (N^2) complexity on specific inputs. Users may notice a noticeable slowdown is observed with inputs above 10k characters. Users who pass user-provided strings without sanity length checks to moment constructor are vulnerable to (Re)DoS attacks. The problem is patched in 2.29.4, the patch can be applied to all affected versions with minimal tweaking. Users are advised to upgrade. Users unable to upgrade should consider limiting date lengths accepted from user input.
AI Analysis
Technical Summary
CVE-2022-31129 is a vulnerability identified in the moment.js JavaScript library, which is widely used for parsing, validating, manipulating, and formatting dates. The vulnerability stems from an inefficient parsing algorithm used specifically in the string-to-date parsing functionality, with a focus on the default rfc2822 date format parsing. The algorithm exhibits quadratic time complexity (O(N^2)) when processing certain crafted inputs, particularly those exceeding 10,000 characters in length. This inefficiency can be exploited by an attacker to cause uncontrolled resource consumption, leading to a Denial of Service (DoS) or more specifically a ReDoS (Regular Expression Denial of Service) attack. The vulnerability affects moment.js versions from 2.18.0 up to but not including 2.29.4. The issue is due to the lack of input length validation or sanitization before parsing, allowing maliciously long strings to trigger excessive CPU usage. The vulnerability has been patched in version 2.29.4, and the fix can be backported with minimal effort. Users who cannot upgrade are advised to implement input length restrictions to mitigate the risk. No known exploits have been reported in the wild to date, but the potential for exploitation exists given the nature of the vulnerability and the widespread use of moment.js in web applications and services.
Potential Impact
For European organizations, the impact of this vulnerability can be significant, especially for those relying on moment.js in web applications, backend services, or client-side scripts that process user-supplied date strings. Exploitation could lead to service degradation or outages due to high CPU consumption, affecting availability and potentially causing denial of service for legitimate users. This can disrupt business operations, degrade user experience, and increase operational costs due to incident response and mitigation efforts. Sectors with high reliance on web services, such as finance, e-commerce, healthcare, and public administration, are particularly vulnerable. Additionally, organizations processing large volumes of user input or integrating third-party services that use moment.js may be indirectly affected. While confidentiality and integrity impacts are minimal, the availability impact is moderate to high depending on the deployment context. The absence of authentication or user interaction requirements for triggering the vulnerability increases the risk, as attackers can exploit it remotely by submitting crafted inputs.
Mitigation Recommendations
1. Upgrade all instances of moment.js to version 2.29.4 or later immediately to apply the official patch addressing the inefficient parsing algorithm. 2. For environments where upgrading is not feasible, implement strict input validation and sanitization, specifically limiting the length of date strings accepted from user inputs to well below 10,000 characters. 3. Employ application-layer rate limiting and input throttling to reduce the risk of automated or bulk exploitation attempts. 4. Monitor application performance metrics and logs for unusual CPU spikes or slowdowns related to date parsing functions. 5. Conduct code audits and dependency reviews to identify and remediate any indirect usage of vulnerable moment.js versions in third-party libraries or microservices. 6. Consider adopting alternative date libraries with more efficient parsing algorithms if moment.js usage is extensive and cannot be fully controlled. 7. Integrate Web Application Firewalls (WAFs) with custom rules to detect and block excessively long or malformed date strings targeting the vulnerable parsing routines.
Affected Countries
Germany, France, United Kingdom, Netherlands, Italy, Spain, Poland, Sweden, Belgium, Ireland
CVE-2022-31129: CWE-400: Uncontrolled Resource Consumption in moment moment
Description
moment is a JavaScript date library for parsing, validating, manipulating, and formatting dates. Affected versions of moment were found to use an inefficient parsing algorithm. Specifically using string-to-date parsing in moment (more specifically rfc2822 parsing, which is tried by default) has quadratic (N^2) complexity on specific inputs. Users may notice a noticeable slowdown is observed with inputs above 10k characters. Users who pass user-provided strings without sanity length checks to moment constructor are vulnerable to (Re)DoS attacks. The problem is patched in 2.29.4, the patch can be applied to all affected versions with minimal tweaking. Users are advised to upgrade. Users unable to upgrade should consider limiting date lengths accepted from user input.
AI-Powered Analysis
Technical Analysis
CVE-2022-31129 is a vulnerability identified in the moment.js JavaScript library, which is widely used for parsing, validating, manipulating, and formatting dates. The vulnerability stems from an inefficient parsing algorithm used specifically in the string-to-date parsing functionality, with a focus on the default rfc2822 date format parsing. The algorithm exhibits quadratic time complexity (O(N^2)) when processing certain crafted inputs, particularly those exceeding 10,000 characters in length. This inefficiency can be exploited by an attacker to cause uncontrolled resource consumption, leading to a Denial of Service (DoS) or more specifically a ReDoS (Regular Expression Denial of Service) attack. The vulnerability affects moment.js versions from 2.18.0 up to but not including 2.29.4. The issue is due to the lack of input length validation or sanitization before parsing, allowing maliciously long strings to trigger excessive CPU usage. The vulnerability has been patched in version 2.29.4, and the fix can be backported with minimal effort. Users who cannot upgrade are advised to implement input length restrictions to mitigate the risk. No known exploits have been reported in the wild to date, but the potential for exploitation exists given the nature of the vulnerability and the widespread use of moment.js in web applications and services.
Potential Impact
For European organizations, the impact of this vulnerability can be significant, especially for those relying on moment.js in web applications, backend services, or client-side scripts that process user-supplied date strings. Exploitation could lead to service degradation or outages due to high CPU consumption, affecting availability and potentially causing denial of service for legitimate users. This can disrupt business operations, degrade user experience, and increase operational costs due to incident response and mitigation efforts. Sectors with high reliance on web services, such as finance, e-commerce, healthcare, and public administration, are particularly vulnerable. Additionally, organizations processing large volumes of user input or integrating third-party services that use moment.js may be indirectly affected. While confidentiality and integrity impacts are minimal, the availability impact is moderate to high depending on the deployment context. The absence of authentication or user interaction requirements for triggering the vulnerability increases the risk, as attackers can exploit it remotely by submitting crafted inputs.
Mitigation Recommendations
1. Upgrade all instances of moment.js to version 2.29.4 or later immediately to apply the official patch addressing the inefficient parsing algorithm. 2. For environments where upgrading is not feasible, implement strict input validation and sanitization, specifically limiting the length of date strings accepted from user inputs to well below 10,000 characters. 3. Employ application-layer rate limiting and input throttling to reduce the risk of automated or bulk exploitation attempts. 4. Monitor application performance metrics and logs for unusual CPU spikes or slowdowns related to date parsing functions. 5. Conduct code audits and dependency reviews to identify and remediate any indirect usage of vulnerable moment.js versions in third-party libraries or microservices. 6. Consider adopting alternative date libraries with more efficient parsing algorithms if moment.js usage is extensive and cannot be fully controlled. 7. Integrate Web Application Firewalls (WAFs) with custom rules to detect and block excessively long or malformed date strings targeting the vulnerable parsing routines.
For access to advanced analysis and higher rate limits, contact root@offseq.com
Technical Details
- Data Version
- 5.1
- Assigner Short Name
- GitHub_M
- Date Reserved
- 2022-05-18T00:00:00.000Z
- Cisa Enriched
- true
Threat ID: 682d9849c4522896dcbf6692
Added to database: 5/21/2025, 9:09:29 AM
Last enriched: 6/22/2025, 12:22:25 AM
Last updated: 7/29/2025, 4:15:51 AM
Views: 13
Related Threats
CVE-2025-9053: SQL Injection in projectworlds Travel Management System
MediumCVE-2025-9052: SQL Injection in projectworlds Travel Management System
MediumCVE-2025-9019: Heap-based Buffer Overflow in tcpreplay
LowCVE-2025-9017: Cross Site Scripting in PHPGurukul Zoo Management System
MediumCVE-2025-9051: SQL Injection in projectworlds Travel Management System
MediumActions
Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.
External Links
Need enhanced features?
Contact root@offseq.com for Pro access with improved analysis and higher rate limits.