CVE-2020-7661: Regular expression denial of service in url-regex

url-regex Updated 02 Oct 2025

Summary

22/06/2020
No i
High
7.5

CVE-2020-7661: Regular expression denial of service in url-regex. Affects url-regex versions < 5.0.0. 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 MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

The url-regex package is an npm package that provides a regular expression for matching URLs. It is commonly used in applications that need to validate or extract URLs from text. The package is vulnerable to a Regular Expression Denial of Service (ReDoS) attack, where an attacker can provide a very long string that causes the regular expression matching to take an excessive amount of time, leading to a denial of service.

Vulnerability Detail

The vulnerability in url-regex arises from the way the regular expression is constructed and the lack of input validation. By providing a specially crafted string in the String.test function, an attacker can trigger a ReDoS attack. This can cause the application to become unresponsive or consume excessive CPU resources, leading to a denial of service. The severity of this vulnerability is rated as HIGH with a CVSS score of 7.5.

How To Fix

No fixed version is published for this vulnerability.

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

Workaround

If updating the package is not immediately feasible, a possible workaround is to implement input validation and limit the length of the input string before passing it to the String.test function. By enforcing a maximum length for the input, the impact of a potential ReDoS attack can be mitigated. Here is an example of how to implement input validation in JavaScript:

const urlRegex = require('url-regex');

function validateUrl(input) {
  const maxLength = 1000; // Set the maximum allowed length
  if (input.length > maxLength) {
    throw new Error('Input exceeds maximum length');
  }

  return urlRegex().test(input);
}

Conclusion

The url-regex package is vulnerable to a Regular Expression Denial of Service (ReDoS) attack. It is recommended to update the package to a version that includes a fix for the vulnerability. If immediate update is not feasible, implementing input validation and limiting the length of the input string can serve as a temporary workaround. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for url-regex →

Share this vulnerability

FAQ

url-regex is an npm package that provides a regular expression for matching URLs. It is commonly used in applications that need to validate or extract URLs from text.

A Regular Expression Denial of Service (ReDoS) attack is a type of denial of service attack where an attacker provides a specially crafted input that causes a regular expression to take an excessive amount of time to match. This can lead to the application becoming unresponsive or consuming excessive resources.

The url-regex vulnerability allows an attacker to trigger a ReDoS attack, leading to a denial of service. This can cause the application to become unresponsive or consume excessive CPU resources.

To fix the url-regex vulnerability, it is recommended to update the package to a version that includes a fix for the ReDoS vulnerability. Developers should check for updates in the npm registry and update their package.json file accordingly.

A possible workaround for the url-regex vulnerability is to implement input validation and limit the length of the input string before passing it to the vulnerable function. By enforcing a maximum length for the input, the impact of a potential ReDoS attack can be mitigated.

Related vulnerabilities

Recent vulnerabilities recorded for url-regex.

How To Fix

No fixed version is published for this vulnerability.

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