CVE-2022-21195: Url regex Denial of Service Vulnerability

MODERATE
Advisory Identifier: GHSA-hg3w-7hj9-m3f7
CVSS 5.3
CWE-1333
Published
Advisory Summary

CVE-2022-21195 is a MODERATE (CVSS 5.3) denial of service vulnerability (CWE-1333: Inefficient Regular Expression Complexity) affecting Url regex libraries in the PyPI ecosystem. The issue involves regular expression denial of service in url_regex. Remediation is available in the latest vendor maintenance releases.

CVE-2022-21195 at a Glance

CVE Identifier CVE-2022-21195
GHSA Identifier GHSA-hg3w-7hj9-m3f7
Severity MODERATE
CVSS v3.1 Base Score 5.3
CWE Classification CWE-1333: Inefficient Regular Expression Complexity
Affected Product Url regex
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 5.3

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability Low (A:L)

How to Fix CVE-2022-21195

To remediate this vulnerability, upgrade all affected Url regex dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

url_regex fixed: Latest secure release
pip install url_regex>=Latest secure release
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show url_regex

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2022-21195, inspect your installed packages using pip:

pip show url_regex

Analyze the terminal output to locate any version of Url regex in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than the patched release), your application is affected.

Note: The pip show url_regex command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-1333: Inefficient Regular Expression Complexity, where the product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential. In Url regex, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

All versions of package url-regex are vulnerable to Regular Expression Denial of Service (ReDoS) which can cause the CPU usage to crash.

CVE-2022-21195 Affected Url regex Versions

1 component(s)
Product / Package Ecosystem Affected Versions Fixed Version
url_regex
PyPI
≤ 1.0.4

References

Frequently Asked Questions

What is CVE-2022-21195?
CVE-2022-21195 is a security vulnerability in Url regex involving Regular expression denial of service in url_regex under CWE-1333: Inefficient Regular Expression Complexity.
Which Url regex versions are affected?
Affected versions include releases prior to current release patches across affected packages: url_regex.
What version fixes CVE-2022-21195?
Upgrading to current release patches (or the latest patched release for your respective branch) resolves the vulnerability.
Is url_regex affected?
Yes, url_regex is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What is the CVSS score of CVE-2022-21195?
CVE-2022-21195 has a CVSS v3.1 base score of 5.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L.
What CWE is associated with CVE-2022-21195?
CVE-2022-21195 is classified under CWE-1333: Inefficient Regular Expression Complexity (The product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential.).
How can I check PyPI dependencies for CVE-2022-21195?
Run the dependency tree command: 'pip show url_regex'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-hg3w-7hj9-m3f7",
  "modified" : "2022-05-25T20:35:04Z",
  "published" : "2022-05-21T00:00:25Z",
  "aliases" : [ "CVE-2022-21195" ],
  "summary" : "Regular expression denial of service in url_regex",
  "details" : "All versions of package url-regex are vulnerable to Regular Expression Denial of Service (ReDoS) which can cause the CPU usage to crash.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "url_regex"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "1.0.4"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-21195"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/AlexFlipnote/url_regex"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/AlexFlipnote/url_regex/blob/master/url_regex/url_regex.py"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-PYTHON-URLREGEX-2347643"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1333" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-05-25T20:35:04Z",
    "nvd_published_at" : "2022-05-20T20:15:00Z"
  }
}