CVE-2025-68142: Pymdown extensions Denial of Service Vulnerability

LOW
Advisory Identifier: GHSA-r6h4-mm7h-8pmq
CWE-1333
Published
Advisory Summary

CVE-2025-68142 is a LOW denial of service vulnerability (CWE-1333: Inefficient Regular Expression Complexity) affecting Pymdown extensions libraries in the PyPI ecosystem. The issue involves pymdown extensions has a redos bug in its figure capture extension. Remediation is available by upgrading affected packages to version 10.16.1.

CVE-2025-68142 at a Glance

CVE Identifier CVE-2025-68142
GHSA Identifier GHSA-r6h4-mm7h-8pmq
Severity LOW
CVSS v3.1 Base Score N/A
CWE Classification CWE-1333: Inefficient Regular Expression Complexity
Affected Product Pymdown extensions
Package Ecosystem PyPI
Published Date
Last Updated

How to Fix CVE-2025-68142

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

pymdown-extensions fixed: 10.16.1
pip install pymdown-extensions>=10.16.1
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 pymdown-extensions

How to Check if You Are Affected

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

pip show pymdown-extensions

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

Note: The pip show pymdown-extensions 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 Pymdown extensions, 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

### Impact This issue describes a ReDOS bug found within the figure caption extension (`pymdownx.blocks.caption` ). In systems that take unchecked user content, this could cause long hangs when processing the data if a malicious payload was crafted. ### Patches This issue is patched in Release [10.16.1](https://pypi.org/project/pymdown-extensions/10.16.1/). ### Workarounds Some possible workarounds If users are concerned about this vulnerability and process unknown user content without timeouts or other safeguards in place to prevent really large, malicious content being aimed at systems, the use of `pymdownx.blocks.caption` could be avoided until the library is updated to 10.16.1+. ### References The original issue https://github.com/facelessuser/pymdown-extensions/issues/2716. ### Description The original issue came through PyMdown Extensions' normal issue tracker instead of the typical security flow: https://github.com/facelessuser/pymdown-extensions/issues/2716. Because this came through the normal issue flow, it was handled as a normal issue. In the future, PyMdown Extensions will ensure such issues, even if prematurely made public through the normal issue flow, are redirected through the typical security process. The regular expression pattern in question is as follows: ```py RE_FIG_NUM = re.compile(r'^(\^)?([1-9][0-9]*(?:.[1-9][0-9]*)*)(?= |$)') ``` The POC was provided by @ShangzhiXu ```py import re import time regex_pattern = re.compile(r'^(\^)?([1-9][0-9]*(?:.[1-9][0-9]*)*)(?= |$)') for i in range(50, 500, 50): long_string = '1' * i + 'a' start_time = time.time() match = re.match(regex_pattern, long_string) end_time = time.time() print(f"long_string execution time: {end_time - start_time:.6f} s") ``` The issue with the above pattern is that `.` was used, which accepts any character when we meant to use `\.`. The fix was to update the pattern to: ```py RE_FIG_NUM = re.compile(r'^(\^)?([1-9][0-9]*(?:\.[1-9][0-9]*)*)(?= |$)') ``` Relevant PR with fix: https://github.com/facelessuser/pymdown-extensions/pull/2717 ### Version(s) & System Info - Operating System: Any - Python Version: Any

CVE-2025-68142 Affected Pymdown extensions Versions

1 component(s)
Fixed Versions:
10.16.1
Product / Package Ecosystem Affected Versions Fixed Version
pymdown-extensions
PyPI
< 10.16.1
10.16.1

References

Frequently Asked Questions

What is CVE-2025-68142?
CVE-2025-68142 is a security vulnerability in Pymdown extensions involving PyMdown Extensions has a ReDOS bug in its Figure Capture extension under CWE-1333: Inefficient Regular Expression Complexity.
Which Pymdown extensions versions are affected?
Affected versions include releases prior to 10.16.1 across affected packages: pymdown-extensions.
What version fixes CVE-2025-68142?
Upgrading to 10.16.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is pymdown-extensions affected?
Yes, pymdown-extensions is affected in releases prior to 10.16.1. Upgrade your dependency to 10.16.1 or later.
What CWE is associated with CVE-2025-68142?
CVE-2025-68142 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-2025-68142?
Run the dependency tree command: 'pip show pymdown-extensions'. 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-r6h4-mm7h-8pmq",
  "modified" : "2025-12-16T20:46:05Z",
  "published" : "2025-12-16T20:46:05Z",
  "aliases" : [ "CVE-2025-68142" ],
  "summary" : "PyMdown Extensions has a ReDOS bug in its Figure Capture extension",
  "details" : "### Impact\n\nThis issue describes a ReDOS bug found within the figure caption extension (`pymdownx.blocks.caption` ).\n\nIn systems that take unchecked user content, this could cause long hangs when processing the data if a malicious payload was crafted.\n\n### Patches\n\nThis issue is patched in Release [10.16.1](https://pypi.org/project/pymdown-extensions/10.16.1/).\n\n### Workarounds\n\nSome possible workarounds\n\nIf users are concerned about this vulnerability and process unknown user content without timeouts or other safeguards in place to prevent really large, malicious content being aimed at systems, the use of `pymdownx.blocks.caption` could be avoided until the library is updated to 10.16.1+.\n\n### References\n\nThe original issue https://github.com/facelessuser/pymdown-extensions/issues/2716.\n\n### Description\n\nThe original issue came through PyMdown Extensions' normal issue tracker instead of the typical security flow: https://github.com/facelessuser/pymdown-extensions/issues/2716. Because this came through the normal issue flow, it was handled as a normal issue. In the future, PyMdown Extensions will ensure such issues, even if prematurely made public through the normal issue flow, are redirected through the typical security process.\n\nThe regular expression pattern in question is as follows:\n\n```py\nRE_FIG_NUM = re.compile(r'^(\\^)?([1-9][0-9]*(?:.[1-9][0-9]*)*)(?= |$)')\n```\n\nThe POC was provided by @ShangzhiXu\n\n```py\nimport re\nimport time\n\nregex_pattern = re.compile(r'^(\\^)?([1-9][0-9]*(?:.[1-9][0-9]*)*)(?= |$)')\n\nfor i in range(50, 500, 50):\n    long_string = '1' * i + 'a'\n    start_time = time.time()\n    match = re.match(regex_pattern, long_string)\n    end_time = time.time()\n    print(f\"long_string execution time: {end_time - start_time:.6f} s\")\n```\n\nThe issue with the above pattern is that `.` was used, which accepts any character when we meant to use `\\.`. The fix was to update the pattern to:\n\n```py\nRE_FIG_NUM = re.compile(r'^(\\^)?([1-9][0-9]*(?:\\.[1-9][0-9]*)*)(?= |$)')\n```\n\nRelevant PR with fix: https://github.com/facelessuser/pymdown-extensions/pull/2717\n\n### Version(s) & System Info\n\n- Operating System: Any\n- Python Version: Any",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N/E:U"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "pymdown-extensions"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "10.16.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/facelessuser/pymdown-extensions/security/advisories/GHSA-r6h4-mm7h-8pmq"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-68142"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/facelessuser/pymdown-extensions/commit/b50d15a56850ed1408a284bba81cc019c6bd72e8"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/facelessuser/pymdown-extensions"
  }, {
    "type" : "WEB",
    "url" : "https://pypi.org/project/pymdown-extensions/10.16.1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1333" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-12-16T20:46:05Z",
    "nvd_published_at" : "2025-12-16T18:16:16Z"
  }
}