Malicious Code Injection in ansi-regex Package: Critical Vulnerability Alert

ansi-regex Updated 02 Oct 2025

Summary

08/09/2025
CRITICAL
No i
Critical
Not published

MAL-2025-46966: Malicious code in ansi-regex (npm). Affects ansi-regex versions 6.2.1. No fix is published. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

The ansi-regex package is a widely used library in the Node.js ecosystem that provides a way to match ANSI escape codes in strings. It is commonly utilized in applications for formatting terminal output. However, a recent compromise has introduced malicious code into version 6.2.1, making it a significant security risk for developers and users alike.

Vulnerability Detail

The vulnerability stems from the introduction of malicious code within the ansi-regex package, specifically in version 6.2.1. This compromise allows attackers to gain unauthorized access to systems where the package is installed, potentially leading to data breaches and the exposure of sensitive information. The malicious code can execute arbitrary commands, thereby compromising the integrity of the host system. Users are advised to treat any system running this package as fully compromised and to take immediate action to secure their environments.

How To Fix

This package is malicious. Remove it and rotate any credentials it could have accessed.

npm uninstall ansi-regex

If it arrived as a transitive dependency, remove the package that pulled it in, then reinstall.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →

Workaround

As a temporary measure, you can remove the affected package from your project until a secure version is confirmed. Use the following command to uninstall the package:

npm uninstall ansi-regex

Additionally, ensure that you rotate any secrets or keys that may have been exposed due to the vulnerability.

Conclusion

The ansi-regex package has been compromised, introducing malicious code that poses a significant security threat. Users must take immediate action to update or remove the affected version to protect their systems. Utilizing tools like Vulert can help monitor for such vulnerabilities in the future.

See every vulnerability recorded for ansi-regex →

Share this vulnerability

FAQ

ansi-regex is a Node.js library used to match ANSI escape codes in strings, commonly used for formatting terminal output.

The package was compromised by the introduction of malicious code in version 6.2.1, which allows unauthorized access to systems.

You should immediately uninstall the affected version and update to the latest version of the package to mitigate the risk.

You can use Vulert, which monitors and alerts for open-source vulnerabilities in your software. Check your application with the Vulert playground at Vulert Scanner.

Failure to address this vulnerability could lead to unauthorized access, data breaches, and loss of sensitive information.

Related vulnerabilities

Recent vulnerabilities recorded for ansi-regex.

How To Fix

This package is malicious. Remove it and rotate any credentials it could have accessed.

npm uninstall ansi-regex

If it arrived as a transitive dependency, remove the package that pulled it in, then reinstall.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback