CVE-2022-24785: Path Traversal 'dir/../../filename' Vulnerability

HIGH
Advisory Identifier: GHSA-8hfj-j24r-96c4
CVSS 7.5
CWE-27 CWE-22
Published
Advisory Summary

CVE-2022-24785 is a HIGH (CVSS 7.5) 'dir/../../filename' vulnerability (CWE-27: Path Traversal: 'dir/../../filename') affecting Path Traversal libraries in the npm ecosystem. The issue involves 'dir/../../filename' in moment.locale. Remediation is available by upgrading affected packages to version 2.29.2.

CVE-2022-24785 at a Glance

CVE Identifier CVE-2022-24785
GHSA Identifier GHSA-8hfj-j24r-96c4
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-27: Path Traversal: 'dir/../../filename'
Affected Product Path Traversal
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2022-24785

To remediate this vulnerability, upgrade all affected Path Traversal dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

moment fixed: 2.29.2
npm install moment@2.29.2
Moment.js fixed: 2.29.2
Upgrade Moment.js to 2.29.2
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls moment

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2022-24785, inspect your project dependencies using npm:

npm ls moment

Analyze the terminal output to locate any version of Path Traversal in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.29.2), your application is affected.

Note: The npm ls moment command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-27: Path Traversal: 'dir/../../filename', where the product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize multiple internal "../" sequences that can resolve to a location that is outside of that directory. In Path Traversal, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact This vulnerability impacts npm (server) users of moment.js, especially if user provided locale string, eg `fr` is directly used to switch moment locale. ### Patches This problem is patched in 2.29.2, and the patch can be applied to all affected versions (from 1.0.1 up until 2.29.1, inclusive). ### Workarounds Sanitize user-provided locale name before passing it to moment.js. ### References _Are there any links users can visit to find out more?_ ### For more information If you have any questions or comments about this advisory: * Open an issue in [moment repo](https://github.com/moment/moment)

CVE-2022-24785 Affected Path Traversal Versions

2 component(s)
Fixed Versions:
2.29.2
Product / Package Ecosystem Affected Versions Fixed Version
moment
npm
< 2.29.2
2.29.2
Moment.js
NuGet
< 2.29.2
2.29.2

References

Frequently Asked Questions

What is CVE-2022-24785?
CVE-2022-24785 is a security vulnerability in Path Traversal involving 'dir/../../filename' in moment.locale under CWE-27: Path Traversal: 'dir/../../filename'.
Which Path Traversal versions are affected?
Affected versions include releases prior to 2.29.2 across affected packages: moment, Moment.js.
What version fixes CVE-2022-24785?
Upgrading to 2.29.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is moment affected?
Yes, moment is affected in releases prior to 2.29.2. Upgrade your dependency to 2.29.2 or later.
Is Moment.js affected?
Yes, Moment.js is affected in releases prior to 2.29.2. Upgrade your dependency to 2.29.2 or later.
What is the CVSS score of CVE-2022-24785?
CVE-2022-24785 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N.
What CWE is associated with CVE-2022-24785?
CVE-2022-24785 is classified under CWE-27: Path Traversal: 'dir/../../filename' (The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize multiple internal "../" sequences that can resolve to a location that is outside of that directory.).
How can I check npm dependencies for CVE-2022-24785?
Run the dependency tree command: 'npm ls moment'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-8hfj-j24r-96c4",
  "modified" : "2025-11-04T16:35:41Z",
  "published" : "2022-04-04T21:25:48Z",
  "aliases" : [ "CVE-2022-24785" ],
  "summary" : "Path Traversal: 'dir/../../filename' in moment.locale",
  "details" : "### Impact\nThis vulnerability impacts npm (server) users of moment.js, especially if user provided locale string, eg `fr` is directly used to switch moment locale.\n\n### Patches\nThis problem is patched in 2.29.2, and the patch can be applied to all affected versions (from 1.0.1 up until 2.29.1, inclusive).\n\n### Workarounds\nSanitize user-provided locale name before passing it to moment.js.\n\n### References\n_Are there any links users can visit to find out more?_\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Open an issue in [moment repo](https://github.com/moment/moment)",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "moment"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.29.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "Moment.js"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.29.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/moment/moment/security/advisories/GHSA-8hfj-j24r-96c4"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-24785"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/moment/moment/commit/4211bfc8f15746be4019bba557e29a7ba83d54c5"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/moment/moment"
  }, {
    "type" : "WEB",
    "url" : "https://lists.debian.org/debian-lts-announce/2023/01/msg00035.html"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/6QIO6YNLTK2T7SPKDS4JEL45FANLNC2Q"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/ORJX2LF6KMPIHP6B2P6KZIVKMLE3LVJ5"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/6QIO6YNLTK2T7SPKDS4JEL45FANLNC2Q"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/ORJX2LF6KMPIHP6B2P6KZIVKMLE3LVJ5"
  }, {
    "type" : "WEB",
    "url" : "https://security.netapp.com/advisory/ntap-20220513-0006"
  }, {
    "type" : "WEB",
    "url" : "https://security.netapp.com/advisory/ntap-20241108-0002"
  }, {
    "type" : "WEB",
    "url" : "https://www.tenable.com/security/tns-2022-09"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22", "CWE-27" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-04-04T21:25:48Z",
    "nvd_published_at" : "2022-04-04T17:15:00Z"
  }
}