moment vulnerable to Path Traversal via crafted non-string locale nameGHSA-4p3w-j4w9-5jqw
MEDIUMFix: moment/moment#6386GHSA-4p3w-j4w9-5jqw is a medium-severity (CVSS 5.9) CWE-27 vulnerability in moment. A fix is available for moment — see the affected versions and patch details below.
Exploitation Status
No confirmed exploitation observed yet
- CISA’s own triage has not observed active exploitation or public proof-of-concept code for this CVE as of its last assessment.
Exploitation and automatability from CISA’s SSVC triage for GHSA-4p3w-j4w9-5jqw.
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
How urgent is this, really
GHSA-4p3w-j4w9-5jqw by exploitation likelihood (EPSS) against impact (CVSS). Outside the shaded patch-first corner.
Where this sits among everything scored
Of 394,803 CVEs with a current EPSS score, this one falls in the < 10% band (highlighted). Counts from FIRST.org, log-scaled.
Real-World Exposure
How broadly this vulnerability is actually deployed: weekly install volume shows current usage, and reverse-dependency count shows how many other packages break if it stays unpatched.
momentnpmDescription
moment is a JavaScript date library for parsing, validating, manipulating, and formatting dates. In versions 2.29.2 through 2.30.1, a specially crafted non-string object passed to moment.locale() can bypass the locale-name path-traversal guard. The guard assumes the input is a string, so an object whose match() method satisfies the check while its toString() returns a traversal path reaches an internal require() call with attacker-controlled path segments. This is an incomplete fix for CVE-2022-24785 and primarily affects npm (server-side) users that pass user-provided input directly to moment.locale(). The issue is fixed in moment 2.31.0, and users should upgrade to 2.31.0 or later. As a workaround, validate that any user-supplied input is a string before passing it to moment.locale().
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 📦npm | moment | ≥ 2.29.2&&< 2.31.0 | 2.31.0npm install moment@2.31.0 |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for moment, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update moment to 2.31.0 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms GHSA-4p3w-j4w9-5jqw is resolved across your whole dependency graph.
Workarounds
Resolve every user-supplied path to its canonical form and reject anything that escapes the intended directory, and run the component under an account that has no read or write access outside the directory it legitimately serves.
Fixing This On Your OS
If you run this on a Linux distribution, patch through your package manager against the distro's own security advisory below — it tracks the exact backported fix for your release, which can ship on a different timeline (and sometimes a different severity) than the upstream project.
Moderate: A path traversal vulnerability exists in the `moment` JavaScript library when specially crafted non-string input is passed to the `moment.locale()` function. This flaw could allow an attacker to access or create files outside of intended directories on systems where user-provided input is directly used by…
To mitigate this issue, implement strict input validation to ensure that all user-supplied data passed to the `moment.locale()` function is a string. This operational control prevents the processing of crafted non-string objects that could lead to path traversal.Source: Red Hat security advisory for GHSA-4p3w-j4w9-5jqw (CC BY 4.0)
Frequently Asked Questions
Is GHSA-4p3w-j4w9-5jqw in your dependencies?
Find it across npm, including transitive dependencies.