# CVE-2022-31129: Moment.js inefficient regular expression in RFC2822 parsing

Source: https://junglewise.ai/threats/cve-2022-31129-moment-js-inefficient-regular-expression-in-rfc2822-parsing  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2022-07-06. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

CVE-2022-31129 · Severity: low · CVSS 3.1 · Published 2022-07-06

Moment.js is a popular JavaScript library used for date and time manipulation in web applications and Node.js services. A ReDoS (Regular Expression Denial of Service) vulnerability in its RFC2822 date parsing allows an attacker to send specially crafted date strings that cause the application to consume excessive CPU resources, leading to service slowdowns or complete unavailability for legitimate users.

Vendors: [NuGet](https://junglewise.ai/threats/vendors/nuget).

## Quick answers

**Is CVE-2022-31129 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2022-31129 being exploited in the wild.

**How severe is CVE-2022-31129?** Low severity, with a CVSS score of 3.1, published 6 July 2022.

**Which products and versions are affected?** Moment.js (NuGet) ECOSYSTEM:introduced=2.18.0,fixed=2.29.4.

**Is there a fix for CVE-2022-31129?** Yes. Moment.js (NuGet): upgrade to 2.29.4 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2022-31129 attacked?** It is attacked over the network, in a software library.

**Am I affected by CVE-2022-31129?** 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.4 or later

  ```sh
  dotnet add package Moment.js --version 2.29.4
  ```


## Technical details

The vulnerability is an inefficient regular expression complexity issue (CWE-1333) in Moment.js's RFC2822 date parsing logic, specifically in the code that removes legacy comments (content within parentheses) from input strings. The regex pattern exhibits quadratic (N²) complexity on certain malicious inputs. An unauthenticated attacker can trigger this by passing a specially crafted string (e.g., repeated opening parentheses) to the moment() constructor; for example, moment("(".repeat(500000)) will consume several minutes of CPU time. No authentication is required, and the attack succeeds with default parsing behavior. The vulnerability affects versions 2.18.0 through 2.29.3 and is patched in version 2.29.4.

## Affected products

- Moment.js Moment.js 2.18.0 through 2.29.3

## Identifiers

- CVE-2022-31129
- GHSA-wc69-rhjr-hc9g

## Timeline

- 2022-07-06: disclosed
- 2022-07-06: patched: Version 2.29.4 released with fix

## References

- [https://github.com/moment/moment/security/advisories/GHSA-wc69-rhjr-hc9g](https://github.com/moment/moment/security/advisories/GHSA-wc69-rhjr-hc9g)

## Related threats

- [moment.js path traversal in locale](https://junglewise.ai/threats/cve-2022-24785-moment-js-path-traversal-in-locale)
