Skip to content
Heist/ feed
Back to feed
High

Inefficient Regular Expression Complexity in moment

Type: advisorySources: OSV

moment is a JavaScript date library for parsing, validating, manipulating, and formatting dates. Affected versions of moment were found to use an inefficient parsing algorithm. Specifically using string-to-date parsing in moment (more specifically rfc2822 parsing, which is tried by default) has quadratic (N^2) complexity on specific inputs. Users may notice a noticeable slowdown is observed with inputs above 10k characters. Users who pass user-provided strings without sanity length checks to moment constructor are vulnerable to (Re)DoS attacks. The problem is patched in 2.29.4, the patch can be applied to all affected versions with minimal tweaking. Users are advised to upgrade. Users unable to upgrade should consider limiting date lengths accepted from user input.

Products
Not specified
Affected versions
Not specified
Fixed versions
Not specified
CVEs
CVE-2022-31129
Confirmed fixed CVEs
Not specified
Updated in this feed
2 Nov 2026, 18:32 UTC · Revision 1

Source evidence

Inefficient Regular Expression Complexity in moment

core-osv · Original source

Published 6 Jul 2022, 00:00 UTC

moment is a JavaScript date library for parsing, validating, manipulating, and formatting dates. Affected versions of moment were found to use an inefficient parsing algorithm. Specifically using string-to-date parsing in moment (more specifically rfc2822 parsing, which is tried by default) has quadratic (N^2) complexity on specific inputs. Users may notice a noticeable slowdown is observed with inputs above 10k characters. Users who pass user-provided strings without sanity length checks to moment constructor are vulnerable to (Re)DoS attacks. The problem is patched in 2.29.4, the patch can be applied to all affected versions with minimal tweaking. Users are advised to upgrade. Users unable to upgrade should consider limiting date lengths accepted from user input.

osv:CVE-2022-31129
Complete source record
{
  "id": "9a39347bc2496384ad4ae21083e4446e65c989e1a39c7318a84211296b4e4db3",
  "url": "https://osv.dev/vulnerability/CVE-2022-31129",
  "method": "structured",
  "payload": {
    "kind": "advisory",
    "title": "Inefficient Regular Expression Complexity in moment",
    "summary": "moment is a JavaScript date library for parsing, validating, manipulating, and formatting dates. Affected versions of moment were found to use an inefficient parsing algorithm. Specifically using string-to-date parsing in moment (more specifically rfc2822 parsing, which is tried by default) has quadratic (N^2) complexity on specific inputs. Users may notice a noticeable slowdown is observed with inputs above 10k characters. Users who pass user-provided strings without sanity length checks to moment constructor are vulnerable to (Re)DoS attacks. The problem is patched in 2.29.4, the patch can be applied to all affected versions with minimal tweaking. Users are advised to upgrade. Users unable to upgrade should consider limiting date lengths accepted from user input.",
    "evidence": "osv:CVE-2022-31129",
    "products": [],
    "severity": "high",
    "structured": {
      "id": "CVE-2022-31129",
      "aliases": [
        "CVE-2022-31129",
        "GHSA-wc69-rhjr-hc9g"
      ],
      "metrics": [
        {
          "type": "CVSS_V3",
          "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
        }
      ],
      "affected": [
        {
          "ranges": [
            {
              "repo": "https://github.com/moment/moment",
              "type": "GIT",
              "events": [
                {
                  "introduced": "f2af24d53ec8bb2ad61626509e529d339217ff96"
                },
                {
                  "fixed": "000ac1800e620f770f4eb31b5ae908f6167b0ab2"
                },
                {
                  "fixed": "9a3b5894f3d5d602948ac8a02e4ee528a49ca3a3"
                }
              ],
              "database_specific": {
                "extracted_events": [
                  {
                    "cpe": "cpe:2.3:a:momentjs:moment:*:*:*:*:*:node.js:*:*",
                    "range": [
                      {
                        "introduced": "2.18.0"
                      },
                      {
                        "fixed": "2.29.4"
                      }
                    ],
                    "source": "CPE_RANGE"
                  },
                  {
                    "cpe": "cpe:2.3:a:momentjs:moment:*:*:*:*:*:nuget:*:*",
                    "range": [
                      {
                        "introduced": "2.18.0"
                      },
                      {
                        "fixed": "2.29.4"
                      }
                    ],
                    "source": "CPE_RANGE"
                  },
                  {
                    "range": [
                      {
                        "fixed": "9a3b5894f3d5d602948ac8a02e4ee528a49ca3a3"
                      }
                    ],
                    "source": "REFERENCES_COMMIT"
                  }
                ]
              }
            }
          ],
          "versions": [
            "2.29.2",
            "2.29.1",
            "2.29.0",
            "2.28.0",
            "2.27.0",
            "2.26.0",
            "2.25.3",
            "2.25.2",
            "2.25.1",
            "2.25.0",
            "2.24.0",
            "2.23.0",
            "2.22.2",
            "2.22.1",
            "2.22.0",
            "2.21.0",
            "2.20.1",
            "2.20.0",
            "2.19.4",
            "2.19.3",
            "2.19.2",
            "2.19.1",
            "2.19.0",
            "2.18.1",
            "2.18.0"
          ],
          "database_specific": {
            "source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2022-31129.json"
          }
        }
      ],
      "modified": "2026-10-28T02:30:22.334216491Z",
      "provider": "osv",
      "references": [
        "https://huntr.dev/bounties/f0952b67-f2ff-44a9-a9cd-99e0a87cb633/",
        "https://github.com/CVEProject/cvelistV5/tree/main/cves/2022/31xxx/CVE-2022-31129.json",
        "https://github.com/moment/moment/security/advisories/GHSA-wc69-rhjr-hc9g",
        "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/6QIO6YNLTK2T7SPKDS4JEL45FANLNC2Q/",
        "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/IWY24RJA3SBJGA5N4CU4VBPHJPPPJL5O/",
        "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/ORJX2LF6KMPIHP6B2P6KZIVKMLE3LVJ5/",
        "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/ZMX5YHELQVCGKKQVFXIYOTBMN23YYSRO/",
        "https://nvd.nist.gov/vuln/detail/CVE-2022-31129",
        "https://security.netapp.com/advisory/ntap-20221014-0003/",
        "https://security.netapp.com/advisory/ntap-20241108-0002/",
        "https://github.com/moment/moment/commit/9a3b5894f3d5d602948ac8a02e4ee528a49ca3a3",
        "https://github.com/moment/moment/pull/6015#issuecomment-1152961973",
        "https://lists.debian.org/debian-lts-announce/2023/01/msg00035.html"
      ],
      "provider_metadata": {
        "cwe_ids": [
          "CWE-400"
        ],
        "cna_assigner": "GitHub_M",
        "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2022/31xxx/CVE-2022-31129.json"
      }
    },
    "related_cves": [
      {
        "value": "CVE-2022-31129",
        "evidence": "/id"
      }
    ],
    "security_relevant": true,
    "severity_evidence": "/severity/0/score"
  },
  "source_id": "core-osv",
  "document_id": 488546,
  "published_at": "2022-07-06T00:00:00+00:00"
}