Regular Expression Denial of Service (ReDoS) in diff npm package

diff Updated 02 Oct 2025

Summary

13/06/2019
HIGH
Yes i
High
Not published

GHSA-h6ch-v84p-w6p9: Regular Expression Denial of Service (ReDoS). Affects diff versions < 3.5.0. Fixed in 3.5.0. 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 Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

The diff npm package is a utility that compares two files and generates a patch file containing the differences between them. It is commonly used in version control systems and file comparison tools. The package provides functions for parsing and applying patches. However, versions of diff before v3.5.0 are vulnerable to Regular Expression Denial of Service (ReDoS) attacks.

Vulnerability Detail

Regular Expression Denial of Service (ReDoS) is a type of vulnerability that occurs when a regular expression pattern is crafted in such a way that it takes a long time to process certain inputs. This can be exploited by an attacker to cause a denial of service by sending specially crafted input that triggers the slow pattern matching. In the case of the diff package, the vulnerable function is diff.parsePatch, which can be abused by an attacker to cause a ReDoS attack. The impact of this vulnerability can range from excessive CPU usage to complete unresponsiveness of the application.

How To Fix

Latest published version: 9.0.0 as of 22 Oct 2026

npm install diff@9.0.0

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

3.5.0

This is the first release that contains the fix.

npm install diff@3.5.0

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

There is no known workaround for this vulnerability. It is crucial to update the package to the latest version to mitigate the risk of ReDoS attacks.

Conclusion

The diff npm package versions prior to 3.5.0 are vulnerable to Regular Expression Denial of Service (ReDoS) attacks. It is crucial to update the package to the latest version to mitigate the risk of this vulnerability. Regularly monitoring for open-source vulnerabilities, such as with Vulert, can help ensure the security of your software.

See every vulnerability recorded for diff →

Share this vulnerability

FAQ

A ReDoS attack is a type of denial of service attack that exploits the inefficiency of certain regular expressions to cause excessive CPU usage or unresponsiveness in an application.

You can use the Vulert Playground at Vulert Scanner to check if your application is affected by this vulnerability. Simply provide your package-lock.json file, and Vulert will analyze it for any open-source vulnerabilities, including this ReDoS vulnerability in the diff package.

It is highly recommended to update the package to the latest version, as it includes a fix specifically for this vulnerability. Manual fixes may not be as effective or comprehensive.

There are no known public exploits of this vulnerability at the time of writing. However, it is always important to stay updated with the latest security patches to protect against potential attacks.

For further support on vulnerability remediation, you can contact info@devnack.com. They can provide guidance and assistance in addressing this vulnerability in your application.

Related vulnerabilities

Recent vulnerabilities recorded for diff.

How To Fix

Latest published version: 9.0.0 as of 22 Oct 2026

npm install diff@9.0.0

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

3.5.0

This is the first release that contains the fix.

npm install diff@3.5.0

Tip — Not sure which version your app runs? Vulert can match this fix to it. 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