CVE-2022-24785: CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') in moment moment
Moment.js is a JavaScript date library for parsing, validating, manipulating, and formatting dates. A path traversal vulnerability impacts npm (server) users of Moment.js between versions 1.0.1 and 2.29.1, especially if a user-provided locale string is directly used to switch moment locale. This problem is patched in 2.29.2, and the patch can be applied to all affected versions. As a workaround, sanitize the user-provided locale name before passing it to Moment.js.
AI Analysis
Technical Summary
CVE-2022-24785 is a path traversal vulnerability identified in Moment.js, a widely used JavaScript library for date parsing, validation, manipulation, and formatting. The vulnerability affects server-side npm users of Moment.js versions from 1.0.1 up to but not including 2.29.2. The core issue arises when a user-supplied locale string is directly used to switch the locale in Moment.js without proper sanitization. This improper limitation of pathname (CWE-22) allows an attacker to craft malicious input that can traverse directories outside the intended locale directory. By exploiting this, an attacker could potentially access or manipulate files on the server that are outside the restricted directory, leading to unauthorized information disclosure or modification of files. The vulnerability is categorized under CWE-22 and CWE-27, indicating improper pathname restrictions and path traversal issues. The problem was patched in version 2.29.2, and the recommended mitigation includes sanitizing user-provided locale strings before passing them to Moment.js. There are no known exploits in the wild as of the published date, and no CVSS score is assigned. The vulnerability primarily impacts server-side applications that dynamically switch locales based on user input without validation, which is a common pattern in internationalized web applications.
Potential Impact
For European organizations, especially those operating web applications or services that utilize Moment.js on the server side for date localization, this vulnerability poses a risk of unauthorized file access or modification. Exploitation could lead to exposure of sensitive configuration files, user data, or other critical resources residing on the server. This could compromise confidentiality and integrity of data, potentially leading to further attacks such as privilege escalation or persistent backdoors. Given the widespread use of Moment.js in web development, organizations with multilingual or localized services are particularly at risk if they accept locale parameters from users without proper sanitization. The impact is heightened in sectors with strict data protection requirements, such as finance, healthcare, and government, where unauthorized data access can lead to regulatory penalties and reputational damage. However, since exploitation requires the application to use user-supplied locale strings directly and no known exploits exist, the immediate risk is moderate but should not be underestimated.
Mitigation Recommendations
1. Upgrade all Moment.js dependencies to version 2.29.2 or later, where the vulnerability is patched. 2. Implement strict input validation and sanitization on all user-supplied locale parameters before passing them to Moment.js. This includes whitelisting allowed locale strings and rejecting or escaping any input containing path traversal characters such as '../' or absolute path indicators. 3. Review server-side code to ensure that locale switching does not rely on unsanitized user input. 4. Employ runtime application self-protection (RASP) or web application firewalls (WAF) with rules to detect and block path traversal attempts targeting locale parameters. 5. Conduct code audits and penetration testing focusing on localization features to identify any residual path traversal risks. 6. Monitor logs for unusual file access patterns or errors related to locale loading that could indicate attempted exploitation. 7. Educate development teams about secure handling of user input in localization contexts to prevent similar vulnerabilities.
Affected Countries
Germany, France, United Kingdom, Netherlands, Italy, Spain, Poland, Sweden, Belgium, Ireland
CVE-2022-24785: CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') in moment moment
Description
Moment.js is a JavaScript date library for parsing, validating, manipulating, and formatting dates. A path traversal vulnerability impacts npm (server) users of Moment.js between versions 1.0.1 and 2.29.1, especially if a user-provided locale string is directly used to switch moment locale. This problem is patched in 2.29.2, and the patch can be applied to all affected versions. As a workaround, sanitize the user-provided locale name before passing it to Moment.js.
AI-Powered Analysis
Technical Analysis
CVE-2022-24785 is a path traversal vulnerability identified in Moment.js, a widely used JavaScript library for date parsing, validation, manipulation, and formatting. The vulnerability affects server-side npm users of Moment.js versions from 1.0.1 up to but not including 2.29.2. The core issue arises when a user-supplied locale string is directly used to switch the locale in Moment.js without proper sanitization. This improper limitation of pathname (CWE-22) allows an attacker to craft malicious input that can traverse directories outside the intended locale directory. By exploiting this, an attacker could potentially access or manipulate files on the server that are outside the restricted directory, leading to unauthorized information disclosure or modification of files. The vulnerability is categorized under CWE-22 and CWE-27, indicating improper pathname restrictions and path traversal issues. The problem was patched in version 2.29.2, and the recommended mitigation includes sanitizing user-provided locale strings before passing them to Moment.js. There are no known exploits in the wild as of the published date, and no CVSS score is assigned. The vulnerability primarily impacts server-side applications that dynamically switch locales based on user input without validation, which is a common pattern in internationalized web applications.
Potential Impact
For European organizations, especially those operating web applications or services that utilize Moment.js on the server side for date localization, this vulnerability poses a risk of unauthorized file access or modification. Exploitation could lead to exposure of sensitive configuration files, user data, or other critical resources residing on the server. This could compromise confidentiality and integrity of data, potentially leading to further attacks such as privilege escalation or persistent backdoors. Given the widespread use of Moment.js in web development, organizations with multilingual or localized services are particularly at risk if they accept locale parameters from users without proper sanitization. The impact is heightened in sectors with strict data protection requirements, such as finance, healthcare, and government, where unauthorized data access can lead to regulatory penalties and reputational damage. However, since exploitation requires the application to use user-supplied locale strings directly and no known exploits exist, the immediate risk is moderate but should not be underestimated.
Mitigation Recommendations
1. Upgrade all Moment.js dependencies to version 2.29.2 or later, where the vulnerability is patched. 2. Implement strict input validation and sanitization on all user-supplied locale parameters before passing them to Moment.js. This includes whitelisting allowed locale strings and rejecting or escaping any input containing path traversal characters such as '../' or absolute path indicators. 3. Review server-side code to ensure that locale switching does not rely on unsanitized user input. 4. Employ runtime application self-protection (RASP) or web application firewalls (WAF) with rules to detect and block path traversal attempts targeting locale parameters. 5. Conduct code audits and penetration testing focusing on localization features to identify any residual path traversal risks. 6. Monitor logs for unusual file access patterns or errors related to locale loading that could indicate attempted exploitation. 7. Educate development teams about secure handling of user input in localization contexts to prevent similar vulnerabilities.
Technical Details
- Data Version
- 5.1
- Assigner Short Name
- GitHub_M
- Date Reserved
- 2022-02-10T00:00:00.000Z
- Cisa Enriched
- true
Threat ID: 682d9843c4522896dcbf2b57
Added to database: 5/21/2025, 9:09:23 AM
Last enriched: 6/23/2025, 11:51:07 AM
Last updated: 2/7/2026, 10:09:08 AM
Views: 54
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Related Threats
CVE-2026-2080: Command Injection in UTT HiPER 810
HighCVE-2026-2079: Improper Authorization in yeqifu warehouse
MediumCVE-2026-1675: CWE-1188 Initialization of a Resource with an Insecure Default in brstefanovic Advanced Country Blocker
MediumCVE-2026-1643: CWE-79 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') in ariagle MP-Ukagaka
MediumCVE-2026-1634: CWE-79 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') in alexdtn Subitem AL Slider
MediumActions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
External Links
Need more coverage?
Upgrade to Pro Console in Console -> Billing for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.