CVE-2022-24785: moment.js path traversal in locale

CVE-2022-24785 · Severity: low · CVSS 3.1 · Published 2022-04-04

moment.js is a popular JavaScript library for parsing, validating, and formatting dates and times, widely used in web applications and Node.js servers. A path traversal vulnerability allows attackers to read arbitrary files from the server by injecting specially crafted locale strings (e.g., using "../" sequences). This impacts applications that allow users to specify locale names without proper validation.

Vendors: NuGet.

Quick answers

Is CVE-2022-24785 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2022-24785 being exploited in the wild.
How severe is CVE-2022-24785?
Low severity, with a CVSS score of 3.1, published 4 April 2022.
Which products and versions are affected?
Moment.js (NuGet) ECOSYSTEM:introduced=0,fixed=2.29.2.
Is there a fix for CVE-2022-24785?
Yes. Moment.js (NuGet): upgrade to 2.29.2 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2022-24785 attacked?
It is attacked over the network, in a software library.
Am I affected by CVE-2022-24785?
Check whether you run Moment.js (NuGet) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • Moment.js (NuGet): upgrade to 2.29.2 or later
    dotnet add package Moment.js --version 2.29.2

Technical details

The vulnerability is a path traversal flaw (CWE-22, CWE-27) in moment.js locale loading functionality. When a user-controlled string is passed to the locale-switching function, the library constructs file paths without properly sanitizing "../" sequences, allowing directory traversal attacks. An attacker can read arbitrary files on the server by crafting a malicious locale string such as "../../etc/passwd". The attack requires the application to accept user input for locale selection and pass it directly to moment.js. This is fixed in version 2.29.2; users of versions 1.0.1 through 2.29.1 should upgrade or sanitize locale input.

Affected products

  • moment.js moment 1.0.1 through 2.29.1

Identifiers

  • CVE-2022-24785
  • GHSA-8hfj-j24r-96c4

Timeline

  • 2022-04-04: disclosed: Publicly disclosed via GHSA-8hfj-j24r-96c4
  • 2022-04-04: patched: Fixed in version 2.29.2

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.