GHSA-r6h4-mm7h-8pmq

Suggest an improvement
Source
https://github.com/advisories/GHSA-r6h4-mm7h-8pmq
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2025/12/GHSA-r6h4-mm7h-8pmq/GHSA-r6h4-mm7h-8pmq.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-r6h4-mm7h-8pmq
Aliases
Published
2025-12-16T20:46:05Z
Modified
2025-12-16T21:17:37.887467Z
Severity
  • 2.7 (Low) CVSS_V4 - 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 CVSS Calculator
Summary
PyMdown Extensions has a ReDOS bug in its Figure Capture extension
Details

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.

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:

RE_FIG_NUM = re.compile(r'^(\^)?([1-9][0-9]*(?:.[1-9][0-9]*)*)(?= |$)')

The POC was provided by @ShangzhiXu

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:

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
Database specific
{
    "severity": "LOW",
    "github_reviewed_at": "2025-12-16T20:46:05Z",
    "cwe_ids": [
        "CWE-1333"
    ],
    "nvd_published_at": "2025-12-16T18:16:16Z",
    "github_reviewed": true
}
References

Affected packages

PyPI / pymdown-extensions

Package

Name
pymdown-extensions
View open source insights on deps.dev
Purl
pkg:pypi/pymdown-extensions

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
10.16.1

Affected versions

1.*

1.0.0
1.0.1
1.1
1.2
1.3
1.4
1.5
1.6
1.6.1
1.7
1.8

2.*

2.0

3.*

3.0
3.1
3.2
3.2.1
3.3
3.4
3.5

4.*

4.0
4.1
4.2
4.3
4.4
4.5
4.5.1
4.6
4.7
4.8
4.9
4.9.1
4.9.2
4.10
4.10.1
4.10.2
4.11
4.12

5.*

5.0

6.*

6.0
6.1
6.2
6.2.1
6.3

7.*

7.0b1
7.0b2
7.0rc1
7.0rc2
7.0
7.1

8.*

8.0
8.0.1
8.1
8.1.1
8.2

9.*

9.0.dev0
9.0
9.1
9.2
9.3
9.4
9.5
9.6
9.7
9.8
9.9
9.9.1
9.9.2
9.10a1
9.10a2
9.10a3
9.10b1
9.10b2
9.10b3
9.10b4
9.10b5
9.10
9.11

10.*

10.0
10.0.1
10.1
10.2
10.2.1
10.3
10.3.1
10.4
10.5
10.6
10.7
10.7.1
10.8
10.8.1
10.9
10.10
10.10.1
10.10.2
10.11
10.11.1
10.11.2
10.12
10.13
10.14
10.14.1
10.14.2
10.14.3
10.15
10.16

Database specific

source

"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2025/12/GHSA-r6h4-mm7h-8pmq/GHSA-r6h4-mm7h-8pmq.json"