The SentinelOne Annual Threat Report - A Defenders Guide from the FrontlinesThe SentinelOne Annual Threat ReportGet the Report
Experiencing a Breach?Blog
Get StartedContact Us
SentinelOne
  • Platform
    Platform Overview
    • Singularity Platform
      Welcome to Integrated Enterprise Security
    • AI for Security
      Leading the Way in AI-Powered Security Solutions
    • Securing AI
      Accelerate AI Adoption with Secure AI Tools, Apps, and Agents.
    • How It Works
      The Singularity XDR Difference
    • Singularity Marketplace
      One-Click Integrations to Unlock the Power of XDR
    • Pricing & Packaging
      Comparisons and Guidance at a Glance
    Data & AI
    • Purple AI
      Accelerate SecOps with Generative AI
    • Singularity Hyperautomation
      Easily Automate Security Processes
    • AI-SIEM
      The AI SIEM for the Autonomous SOC
    • Singularity Data Lake
      AI-Powered, Unified Data Lake
    • Singularity Data Lake for Log Analytics
      Seamlessly Ingest Data from On-Prem, Cloud or Hybrid Environments
    Endpoint Security
    • Singularity Endpoint
      Autonomous Prevention, Detection, and Response
    • Singularity XDR
      Native & Open Protection, Detection, and Response
    • Singularity RemoteOps Forensics
      Orchestrate Forensics at Scale
    • Singularity Threat Intelligence
      Comprehensive Adversary Intelligence
    • Singularity Vulnerability Management
      Application & OS Vulnerability Management
    • Singularity Identity
      Identity Threat Detection and Response
    Cloud Security
    • Singularity Cloud Security
      Block Attacks with an AI-Powered CNAPP
    • Singularity Cloud Native Security
      Secure Cloud and Development Resources
    • Singularity Cloud Workload Security
      Real-Time Cloud Workload Protection Platform
    • Singularity Cloud Data Security
      AI-Powered Threat Detection for Cloud Storage
    • Singularity Cloud Security Posture Management
      Detect and Remediate Cloud Misconfigurations
    Securing AI
    • Prompt Security
      Secure AI Tools Across Your Enterprise
  • Why SentinelOne?
    Why SentinelOne?
    • Why SentinelOne?
      Cybersecurity Built for What’s Next
    • Our Customers
      Trusted by the World’s Leading Enterprises
    • Industry Recognition
      Tested and Proven by the Experts
    • About Us
      The Industry Leader in Autonomous Cybersecurity
    Compare SentinelOne
    • Arctic Wolf
    • Broadcom
    • CrowdStrike
    • Cybereason
    • Microsoft
    • Palo Alto Networks
    • Sophos
    • Splunk
    • Trellix
    • Trend Micro
    • Wiz
    Verticals
    • Energy
    • Federal Government
    • Finance
    • Healthcare
    • Higher Education
    • K-12 Education
    • Manufacturing
    • Retail
    • State and Local Government
  • Services
    Managed Services
    • Managed Services Overview
      Wayfinder Threat Detection & Response
    • Threat Hunting
      World-Class Expertise and Threat Intelligence
    • Managed Detection & Response
      24/7/365 Expert MDR Across Your Entire Environment
    • Incident Readiness & Response
      DFIR, Breach Readiness, & Compromise Assessments
    Support, Deployment, & Health
    • Technical Account Management
      Customer Success with Personalized Service
    • SentinelOne GO
      Guided Onboarding & Deployment Advisory
    • SentinelOne University
      Live and On-Demand Training
    • Services Overview
      Comprehensive Solutions for Seamless Security Operations
    • SentinelOne Community
      Community Login
  • Partners
    Our Network
    • MSSP Partners
      Succeed Faster with SentinelOne
    • Singularity Marketplace
      Extend the Power of S1 Technology
    • Cyber Risk Partners
      Enlist Pro Response and Advisory Teams
    • Technology Alliances
      Integrated, Enterprise-Scale Solutions
    • SentinelOne for AWS
      Hosted in AWS Regions Around the World
    • Channel Partners
      Deliver the Right Solutions, Together
    • SentinelOne for Google Cloud
      Unified, Autonomous Security Giving Defenders the Advantage at Global Scale
    • Partner Locator
      Your Go-to Source for Our Top Partners in Your Region
    Partner Portal→
  • Resources
    Resource Center
    • Case Studies
    • Data Sheets
    • eBooks
    • Reports
    • Videos
    • Webinars
    • Whitepapers
    • Events
    View All Resources→
    Blog
    • Feature Spotlight
    • For CISO/CIO
    • From the Front Lines
    • Identity
    • Cloud
    • macOS
    • SentinelOne Blog
    Blog→
    Tech Resources
    • SentinelLABS
    • Ransomware Anthology
    • Cybersecurity 101
  • About
    About SentinelOne
    • About SentinelOne
      The Industry Leader in Cybersecurity
    • Investor Relations
      Financial Information & Events
    • SentinelLABS
      Threat Research for the Modern Threat Hunter
    • Careers
      The Latest Job Opportunities
    • Press & News
      Company Announcements
    • Cybersecurity Blog
      The Latest Cybersecurity Threats, News, & More
    • FAQ
      Get Answers to Our Most Frequently Asked Questions
    • DataSet
      The Live Data Platform
    • S Foundation
      Securing a Safer Future for All
    • S Ventures
      Investing in the Next Generation of Security, Data and AI
  • Pricing
Get StartedContact Us
CVE Vulnerability Database
Vulnerability Database/CVE-2022-31129

CVE-2022-31129: Moment.js ReDoS Vulnerability

CVE-2022-31129 is a Regular Expression Denial of Service vulnerability in Moment.js that causes quadratic complexity during date parsing. This article covers the technical details, affected versions, impact, and mitigation.

Published: February 18, 2026

CVE-2022-31129 Overview

CVE-2022-31129 is a Regular Expression Denial of Service (ReDoS) vulnerability affecting Moment.js, a widely-used JavaScript date library for parsing, validating, manipulating, and formatting dates. The vulnerability exists in the RFC2822 date parsing functionality, which is attempted by default when parsing date strings. The inefficient parsing algorithm exhibits quadratic (N^2) complexity on specific inputs, allowing attackers to cause significant application slowdowns or complete denial of service.

Critical Impact

Applications accepting user-provided date strings without length validation are vulnerable to denial of service attacks, potentially causing service unavailability for all users.

Affected Products

  • Momentjs Moment (versions prior to 2.29.4 for Node.js)
  • Momentjs Moment (versions prior to 2.29.4 for NuGet)
  • Fedoraproject Fedora (versions 35, 36, 37)
  • Debian Debian Linux (version 10.0)

Discovery Timeline

  • 2022-07-06 - CVE-2022-31129 published to NVD
  • 2025-11-03 - Last updated in NVD database

Technical Details for CVE-2022-31129

Vulnerability Analysis

The vulnerability resides in the preprocessRFC2822 function within Moment.js's date string parsing module. This function processes RFC2822 formatted date strings by removing comments, folding whitespace, and normalizing spaces. The core issue stems from an inefficient regular expression pattern that exhibits catastrophic backtracking behavior when processing maliciously crafted input strings.

When Moment.js attempts to parse a date string, it tries multiple parsing strategies including RFC2822 format by default. The vulnerable regex pattern /\([^)]*\)/g was designed to strip parenthesized comments from RFC2822 date strings. However, this pattern becomes problematic when encountering nested or unmatched parentheses, causing the regex engine to explore an exponentially growing number of potential matches.

Users passing strings exceeding 10,000 characters to the Moment.js constructor may observe noticeable slowdowns. Larger inputs can completely freeze the JavaScript event loop, effectively denying service to all application users.

Root Cause

The root cause is an inefficient regular expression in the preprocessRFC2822 function that exhibits quadratic time complexity (O(n²)) due to catastrophic backtracking. The original regex pattern /\([^)]*\)/g was designed to match and remove parenthetical comments but failed to account for nested parentheses or malformed input, causing the regex engine to perform excessive backtracking operations on crafted inputs.

Attack Vector

The attack vector is network-based, requiring no authentication or user interaction. An attacker can exploit this vulnerability by sending HTTP requests containing specially crafted date strings to any endpoint that processes user input through Moment.js. The attack requires:

  1. Identification of an application endpoint accepting date strings
  2. Crafting a malicious string with patterns that trigger catastrophic backtracking
  3. Sending the payload to exhaust server CPU resources

Applications that accept user-provided strings and pass them directly to the moment() constructor without input length validation are particularly vulnerable. This is common in web applications processing form data, API requests, or importing data from external sources.

javascript
// Security patch for preprocessRFC2822 function
// Source: https://github.com/moment/moment/commit/9a3b5894f3d5d602948ac8a02e4ee528a49ca3a3

 function preprocessRFC2822(s) {
     // Remove comments and folding whitespace and replace multiple-spaces with a single space
     return s
-        .replace(/\([^)]*\)|[\n\t]/g, ' ')
+        .replace(/\([^()]*\)|[\n\t]/g, ' ')
         .replace(/(\s\s+)/g, ' ')
         .replace(/^\s\s*/, '')
         .replace(/\s\s*$/g, '');

The fix changes the regex pattern from \([^)]*\) to \([^()]*\), preventing the engine from matching nested parentheses and eliminating the catastrophic backtracking behavior.

Detection Methods for CVE-2022-31129

Indicators of Compromise

  • Unusual CPU utilization spikes on web application servers during date parsing operations
  • Significant increase in response times for API endpoints accepting date parameters
  • Application timeouts or unresponsive behavior when processing date strings
  • Error logs showing JavaScript execution timeouts or event loop blocking

Detection Strategies

  • Monitor application performance metrics for sudden CPU spikes correlated with date parsing requests
  • Implement request logging to identify unusually large payloads in date-related fields
  • Use software composition analysis (SCA) tools to identify vulnerable Moment.js versions in dependencies
  • Review application code for direct usage of moment() constructor with user-provided input

Monitoring Recommendations

  • Configure application performance monitoring (APM) to alert on elevated response times for date-processing endpoints
  • Set up resource utilization alerts for CPU thresholds that may indicate ReDoS exploitation
  • Implement request size monitoring to detect anomalously large input payloads
  • Enable verbose logging for date parsing operations in staging environments to identify potential attack patterns

How to Mitigate CVE-2022-31129

Immediate Actions Required

  • Upgrade Moment.js to version 2.29.4 or later immediately
  • Implement input length validation for all date strings before passing to Moment.js
  • Audit application code for direct usage of moment() constructor with user-controlled input
  • Consider migrating to actively maintained alternatives such as date-fns or Luxon

Patch Information

The vulnerability is patched in Moment.js version 2.29.4. The patch modifies the regular expression in the preprocessRFC2822 function to prevent catastrophic backtracking. Organizations should update via their package manager:

For npm: npm update moment or npm install moment@2.29.4
For yarn: yarn upgrade moment@2.29.4

The GitHub commit contains the minimal change required, which can be backported to older versions if upgrading is not immediately feasible. Additional details are available in the GitHub Security Advisory.

Workarounds

  • Implement strict input length limits (e.g., 200 characters) for date strings before parsing
  • Use explicit date format strings instead of relying on automatic format detection
  • Wrap Moment.js parsing in try-catch with timeout mechanisms
  • Consider using moment.utc() or moment.parseZone() with explicit formats to bypass RFC2822 parsing
bash
# Configuration example - Input validation before Moment.js parsing
# Implement in your application's input validation layer

# Example npm command to check for vulnerable versions
npm list moment

# Example to update to patched version
npm install moment@2.29.4 --save

# Verify installed version
npm list moment | grep moment

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

  • Vulnerability Details
  • TypeDOS

  • Vendor/TechMomentjs

  • SeverityHIGH

  • CVSS Score7.5

  • EPSS Probability3.44%

  • Known ExploitedNo
  • CVSS Vector
  • CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
  • Impact Assessment
  • ConfidentialityLow
  • IntegrityNone
  • AvailabilityHigh
  • CWE References
  • CWE-400

  • CWE-1333
  • Technical References
  • GitHub Security Advisory

  • Debian LTS Announcement

  • Fedora Package Announcement

  • Fedora Package Announcement

  • Fedora Package Announcement

  • Fedora Package Announcement

  • NetApp Security Advisory

  • NetApp Security Advisory
  • Vendor Resources
  • GitHub Commit Update

  • GitHub Pull Request Comment

  • Huntr Bounty Disclosure
  • Related CVEs
  • CVE-2022-24785: Moment.js Path Traversal Vulnerability
Experience the World’s Most Advanced Cybersecurity Platform

Experience the World’s Most Advanced Cybersecurity Platform

See how our intelligent, autonomous cybersecurity platform can protect your organization now and into the future.

Try SentinelOne
  • Get Started
  • Get a Demo
  • Product Tour
  • Why SentinelOne
  • Pricing & Packaging
  • FAQ
  • Contact
  • Contact Us
  • Customer Support
  • SentinelOne Status
  • Language
  • Platform
  • Singularity Platform
  • Singularity Endpoint
  • Singularity Cloud
  • Singularity AI-SIEM
  • Singularity Identity
  • Singularity Marketplace
  • Purple AI
  • Services
  • Wayfinder TDR
  • SentinelOne GO
  • Technical Account Management
  • Support Services
  • Verticals
  • Energy
  • Federal Government
  • Finance
  • Healthcare
  • Higher Education
  • K-12 Education
  • Manufacturing
  • Retail
  • State and Local Government
  • Cybersecurity for SMB
  • Resources
  • Blog
  • Labs
  • Case Studies
  • Videos
  • Product Tours
  • Events
  • Cybersecurity 101
  • eBooks
  • Webinars
  • Whitepapers
  • Press
  • News
  • Ransomware Anthology
  • Company
  • About Us
  • Our Customers
  • Careers
  • Partners
  • Legal & Compliance
  • Security & Compliance
  • Investor Relations
  • S Foundation
  • S Ventures

©2026 SentinelOne, All Rights Reserved.

Privacy Notice Terms of Use

English