Vulnerabilities in pkg:pypi/markdown2

PACKAGE
Advisory Identifier: GHSA-jr9p-r423-9m2r
Advisory Summary

CVE-2021-26813 is a HIGH (CVSS 7.5) denial of service vulnerability (CWE-1333: Inefficient Regular Expression Complexity) affecting Markdown2 libraries in the PyPI ecosystem. The issue involves markdown2 regular expression denial of service. Remediation is available by upgrading affected packages to version 2.4.0.

4 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:pypi/markdown2

4 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:pypi/markdown2. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-jr9p-r423-9m2r CVE-2021-26813 HIGH markdown2 Regular Expression Denial of Service
GHSA-p6h9-gw49-rqm4 CVE-2018-5773 MODERATE markdown2 is vulnerable to cross-site scripting
GHSA-72cx-5ff9-4hhc CVE-2009-3724 MODERATE Cross-site scripting in markdown2 for python
GHSA-fv3h-8x5j-pvgq CVE-2020-11888 MODERATE XSS in python-markdown2

CVE-2021-26813 at a Glance

CVE Identifier CVE-2021-26813
GHSA Identifier GHSA-jr9p-r423-9m2r
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-1333: Inefficient Regular Expression Complexity
Affected Product Markdown2
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.5

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:H).

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 High (A:H)

How to Fix CVE-2021-26813

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

markdown2 fixed: 2.4.0
pip install markdown2>=2.4.0
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 markdown2

How to Check if You Are Affected

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

pip show markdown2

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

Note: The pip show markdown2 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 Markdown2, 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

markdown2 >=1.0.1.18, fixed in 2.4.0, is affected by a regular expression denial of service vulnerability. If an attacker provides a malicious string, it can make markdown2 processing difficult or delayed for an extended period of time.

CVE-2021-26813 Affected Markdown2 Versions

1 component(s)
Fixed Versions:
2.4.0
Product / Package Ecosystem Affected Versions Fixed Version
markdown2
PyPI
≥ 1.0.1.18
< 2.4.0
2.4.0

References

Frequently Asked Questions

What is CVE-2021-26813?
CVE-2021-26813 is a security vulnerability in Markdown2 involving markdown2 Regular Expression Denial of Service under CWE-1333: Inefficient Regular Expression Complexity.
Which Markdown2 versions are affected?
Affected versions include releases prior to 2.4.0 across affected packages: markdown2.
What version fixes CVE-2021-26813?
Upgrading to 2.4.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is markdown2 affected?
Yes, markdown2 is affected in releases prior to 2.4.0. Upgrade your dependency to 2.4.0 or later.
What is the CVSS score of CVE-2021-26813?
CVE-2021-26813 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2021-26813?
CVE-2021-26813 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-2021-26813?
Run the dependency tree command: 'pip show markdown2'. 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-jr9p-r423-9m2r",
  "modified" : "2024-09-30T20:15:06Z",
  "published" : "2021-06-02T21:44:28Z",
  "aliases" : [ "CVE-2021-26813" ],
  "summary" : "markdown2 Regular Expression Denial of Service ",
  "details" : "markdown2 >=1.0.1.18, fixed in 2.4.0, is affected by a regular expression denial of service vulnerability. If an attacker provides a malicious string, it can make markdown2 processing difficult or delayed for an extended period of time.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "markdown2"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.0.1.18"
      }, {
        "fixed" : "2.4.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-26813"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/trentm/python-markdown2/pull/387"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/trentm/python-markdown2/commit/7b651260739647de5198323e0445b1618750c374"
  }, {
    "type" : "ADVISORY",
    "url" : "https://github.com/advisories/GHSA-jr9p-r423-9m2r"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/markdown2/PYSEC-2021-20.yaml"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/trentm/python-markdown2"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/BRP5RN35JZTSJ3JT4722F447ZDK7LZS5"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/J752422YELXLMLZJPVJVKD2KKHHQRVEH"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/JTIX5UXRDJZJ57DO4V33ZNJTNKWGBQLY"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1333" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-05-12T21:02:47Z",
    "nvd_published_at" : "2021-03-03T16:15:00Z"
  }
}