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
    • AI Data Pipelines
      Security Data Pipeline for AI SIEM and Data Optimization
    • 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-2021-3807

CVE-2021-3807: Ansi-regex DOS Vulnerability

CVE-2021-3807 is a denial of service vulnerability in Ansi-regex caused by inefficient regular expression complexity. Attackers can exploit this flaw to exhaust system resources. This article covers technical details, affected versions, impact assessment, and mitigation strategies.

Published: February 25, 2026

CVE-2021-3807 Overview

CVE-2021-3807 is a Regular Expression Denial of Service (ReDoS) vulnerability in the ansi-regex package for Node.js. The vulnerability stems from an inefficient regular expression pattern that can be exploited to cause catastrophic backtracking when processing specially crafted input strings. This can lead to significant CPU resource exhaustion and denial of service conditions in applications that rely on ansi-regex for stripping ANSI escape codes from strings.

Critical Impact

Applications using vulnerable versions of ansi-regex can be rendered unresponsive through crafted input strings that trigger exponential regex backtracking, leading to denial of service conditions in Node.js environments.

Affected Products

  • ansi-regex versions prior to 5.0.1 (for 5.x branch)
  • ansi-regex versions prior to 6.0.1 (for 6.x branch)
  • Oracle Communications Cloud Native Core Policy 1.15.0

Discovery Timeline

  • 2021-09-17 - CVE CVE-2021-3807 published to NVD
  • 2024-11-21 - Last updated in NVD database

Technical Details for CVE-2021-3807

Vulnerability Analysis

The ansi-regex package provides a regular expression for matching ANSI escape codes in strings. The vulnerability exists in the regex pattern used to identify these escape sequences. The original pattern contained nested quantifiers and alternations that could lead to catastrophic backtracking when processing malicious input.

When the regex engine encounters certain crafted strings, it attempts to match the pattern through an exponentially increasing number of possible paths. This behavior, known as ReDoS (Regular Expression Denial of Service), can cause the Node.js event loop to block for extended periods, effectively denying service to legitimate requests.

The vulnerability affects any application that processes untrusted input through the ansi-regex pattern, including CLI tools, logging systems, and web applications that handle terminal output.

Root Cause

The root cause is an inefficient regular expression pattern with problematic nested quantifiers. The original pattern [a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)* allowed for ambiguous matching paths that the regex engine would explore exhaustively when given adversarial input. The combination of the * quantifier applied to character classes within nested groups created exponential time complexity.

Attack Vector

An attacker can exploit this vulnerability by sending specially crafted strings containing sequences that trigger catastrophic backtracking in the regex engine. This is a network-accessible attack requiring no authentication or user interaction, making it particularly dangerous for public-facing applications.

The attack requires the ability to provide input that gets processed by the ansi-regex pattern. Common attack surfaces include:

  • Command-line argument processing
  • Log message handling
  • API endpoints that process terminal-formatted text
  • Web sockets or real-time messaging systems
javascript
export default function ansiRegex({onlyFirst = false} = {}) {
	const pattern = [
-		'[\\\u001B\\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\\u0007)',
+	    '[\\\u001B\\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\\u0007)',
		'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))
	].join('|');

Source: GitHub Commit

Detection Methods for CVE-2021-3807

Indicators of Compromise

  • Unusual CPU spikes in Node.js processes handling string input
  • Blocked or unresponsive event loops in application monitoring
  • Timeouts in request processing with no obvious cause
  • Memory pressure increases accompanying high CPU utilization

Detection Strategies

  • Implement Software Composition Analysis (SCA) scanning to identify vulnerable ansi-regex versions in your dependency tree
  • Monitor Node.js process CPU utilization for sustained spikes during input processing
  • Use application performance monitoring (APM) tools to detect event loop blocking
  • Review package-lock.json or yarn.lock files for vulnerable versions of ansi-regex

Monitoring Recommendations

  • Set up alerts for Node.js process CPU utilization exceeding normal thresholds
  • Monitor request latency metrics for sudden increases
  • Implement timeout mechanisms for string processing operations
  • Use npm audit or similar dependency scanning tools in CI/CD pipelines

How to Mitigate CVE-2021-3807

Immediate Actions Required

  • Upgrade ansi-regex to version 5.0.1 or later (for 5.x users)
  • Upgrade ansi-regex to version 6.0.1 or later (for 6.x users)
  • Run npm audit fix to automatically resolve dependency vulnerabilities
  • Review and update transitive dependencies that may include vulnerable ansi-regex versions

Patch Information

The vulnerability has been addressed in ansi-regex versions 5.0.1 and 6.0.1. The fix modifies the regular expression pattern to eliminate the nested quantifier issue that caused catastrophic backtracking. The patch can be reviewed in the GitHub commit. Oracle has also addressed this vulnerability in their products through the April 2022 Critical Patch Update.

Workarounds

  • Implement input length limits on strings processed by ansi-regex
  • Add timeout mechanisms for regex operations using safe-regex or similar libraries
  • Consider using alternative ANSI stripping methods that don't rely on vulnerable regex patterns
  • Isolate string processing into worker threads to prevent main event loop blocking
bash
# Upgrade ansi-regex to patched version
npm update ansi-regex

# Or force resolution in package.json (npm 8.3+)
# Add to package.json:
# "overrides": {
#   "ansi-regex": "^5.0.1"
# }

# For yarn users, add to package.json:
# "resolutions": {
#   "ansi-regex": "^5.0.1"
# }

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

  • Vulnerability Details
  • TypeDOS

  • Vendor/TechAnsi Regex

  • SeverityHIGH

  • CVSS Score7.5

  • EPSS Probability0.21%

  • 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-1333
  • Technical References
  • NetApp Security Advisory
  • Vendor Resources
  • GitHub Commit Update

  • Huntr Vulnerability Bounty

  • Oracle Security Alert
  • Latest CVEs
  • CVE-2025-9185: Mozilla Firefox RCE Vulnerability

  • CVE-2025-9184: Mozilla Firefox RCE Vulnerability

  • CVE-2025-9180: Mozilla Firefox Auth Bypass Vulnerability

  • CVE-2025-8030: Mozilla Firefox RCE Vulnerability
Default Legacy - Prefooter | 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