Skip to main content

pymdown-extensions CVE-2026-46338

| EUVDEUVD-2026-45003 MEDIUM
Path Traversal (CWE-22)
2026-05-19 https://github.com/facelessuser/pymdown-extensions GHSA-62q4-447f-wv8h PYSEC-2026-2999
4.3
CVSS 3.1 · Vendor: https://github.com/facelessuser/pymdown-extensions
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Recon
    Submit malicious markdown with crafted snippet directive
  2. Delivery
    CI pipeline triggers mkdocs build
  3. Exploit
    pymdownx.snippets resolves path via os.path.abspath
  4. Install
    Flawed startswith() check passes for sibling directory
  5. C2
    File read succeeds outside base_path
  6. Execute
    Leaked content embedded in generated HTML
  7. Impact
    Published documentation exposes exfiltrated data

Vulnerability Assessment

Weakness
CWE
OWASP Top 10:2025
A01:2025 - Broken Access Control
ASVS 5.0
V5 - File Handling Path canonicalization, traversal prevention
MITRE ATT&CK

2 techniques across 2 tactics: Discovery, Collection

The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up.

Exploitation Conditions

No non-default configuration is required - restrict_base_path: True is the default setting for pymdownx.snippets, and the vulnerable startswith() check is the active code path under that default. For exploitation to succeed: (1) the target must be running pymdown-extensions version 10.0.1 through 10.21.2; (2) the build host filesystem must have at least one sibling directory whose absolute path shares the same string prefix as the configured base_path (e.g., /x/docs and /x/docs_secret); (3) the attacker must be able to inject or submit a markdown file containing a crafted --8<-- snippet directive (typical in PR-based CI workflows); (4) a build process must execute to render the markdown (the UI:R in the CVSS vector represents this build trigger). Exploitation is limited to files in sibling directories whose names begin with the same string as base_path - arbitrary filesystem traversal to unrelated paths is not possible. Symlinks within base_path pointing outside are a separate concern not addressed by this CVE.

Impact

The CVSS 4.3 Medium score (AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:N/A:N) reflects network-accessible exploitation with no authentication required (PR:N) and low attack complexity, but bounded confidentiality impact (C:L) and a user-interaction requirement (UI:R, representing the CI build process that must render the markdown). Despite the moderate CVSS score, real-world risk is elevated in CI/CD environments processing PR-contributed markdown: a contributor-submitted malicious snippet file can silently exfiltrate secrets from sibling directories and publish them in generated HTML documentation. The threat model directly parallels the predecessor CVE-2023-32309, which was previously exploited in documentation pipelines. EPSS data was not provided in the available intelligence, preventing probabilistic exploitation-rate assessment. The vulnerability is not listed in CISA KEV, indicating no confirmed mass exploitation at time of analysis. However, a fully functional PoC is published in the GitHub Security Advisory, lowering the bar for exploitation significantly. The impact is bounded to sibling directories whose names share a string prefix with base_path (e.g., /x/docs_internal or /x/docs.bak when base is /x/docs), which narrows the blast radius but does not eliminate secrets exposure in typical MkDocs CI deployments.

Exploit ScenarioDerived

An attacker submits a pull request to an open-source MkDocs project hosted on GitHub, inserting the snippet directive '--8<-- "../docs_secret/secret.env"' into a markdown file. When the CI pipeline renders the documentation (e.g., via mkdocs build), pymdownx.snippets resolves the path to /workspace/docs_secret/secret.env, which passes the flawed startswith('/workspace/docs') check, and the file contents are silently embedded into the generated HTML. The published documentation site then exposes the secret file contents to anyone who views the page. A fully functional PoC demonstrating this flow is included in the GitHub Security Advisory.

This Month Plan within 30 days. Why: MEDIUM severity (CVSS 4.0-6.9).
Patch available 0.0% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – May 19, 2026

Path traversal in pymdownx.snippets versions 10.0.1 through 10.21.2 allows unauthenticated remote attackers to read arbitrary files from sibling directories outside the configured base_path, bypassing the restrict_base_path protection intended by CVE-2023-32309. The bypass exploits a string-prefix comparison introduced in PR #2039 that lacks directory-boundary enforcement, enabling a crafted snippet directive like '--8<-- "../docs_secret/leak.txt"' to escape the configured base directory when sibling paths share the same string prefix. Publicly available exploit code (proof-of-concept) exists in the GitHub Security Advisory; the vulnerability is not confirmed actively exploited in the CISA KEV catalog at time of analysis.

RemediationAI

Upgrade pymdown-extensions to version 10.21.3, which is confirmed as the fixed release per the GHSA-62q4-447f-wv8h advisory (https://github.com/facelessuser/pymdown-extensions/security/advisories/GHSA-62q4-447f-wv8h). The fix changes the containment check in pymdownx/snippets.py from filename.startswith(base) to filename.startswith(base + os.sep), restoring directory-boundary enforcement while preserving support for snippets nested at arbitrary depth under base_path. If an immediate upgrade is not possible, compensating controls include: (1) restricting who can submit or modify markdown files processed by the snippets extension in CI - this eliminates untrusted-contributor access but requires strict branch protection; (2) ensuring no sensitive secrets or files reside in any directory whose name shares a string prefix with the configured base_path on the build host - this limits the blast radius but is operationally fragile; (3) running the documentation build in an isolated container or sandbox where the filesystem contains only the docs directory tree, preventing sibling paths from existing - this is the most reliable workaround and has no functional trade-offs beyond added build infrastructure complexity. Do not rely on setting restrict_base_path: True as a security control until upgraded, as that setting is vulnerable by design in affected versions.

Affected VersionsENISA

pymdown-extensions 10.0.1, < 10.21.3

Affected Packages

pypi pymdown-extensions fix: 10.21.3

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 1 package in pypi

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

The vulnerability resides in SnippetPreprocessor.get_snippet_path() within pymdownx/snippets.py (package: pkg:pip/pymdown-extensions). The root cause class is CWE-22 (Improper Limitation of a Pathname to a Restricted Directory). The original CVE-2023-32309 fix used os.path.samefile(base, os.path.dirname(filename)) to verify directory identity, but PR #2039 (commit 7c13bda5b7793b172efd1abb6712e156a83fe07d, 2023-05-15) replaced this with filename.startswith(base), where base is os.path.abspath(b) with no trailing separator. Because Python's str.startswith() performs a raw character comparison, a resolved path like /x/docs_secret/leak.txt satisfies startswith('/x/docs') even though /x/docs_secret is a sibling directory, not a subdirectory. The Markdown Snippet extension processes '--8<-- path' directives at build time, so any markdown pipeline using pymdownx.snippets with restrict_base_path: True (the default) is affected on any platform where sibling paths with shared prefixes exist.

Know when Python gets its next vulnerability

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

Vendor (https://github.com/facelessuser/pymdown-extensions) PRIMARY 4.3 MEDIUM
AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:N/A:N
Red Hat 4.3 MEDIUM

Primary rating from Vendor (https://github.com/facelessuser/pymdown-extensions).

CVSS VectorVendor: https://github.com/facelessuser/pymdown-extensions

Attack Vector
Network
Attack Complexity
Low
Privileges Required
None
User Interaction
Required
Scope
Unchanged
Confidentiality
Low
Integrity
None
Availability
None

DescriptionCVE.org

Summary

pymdownx.snippets has a regression of the CVE-2023-32309 / GHSA-jh85-wwv9-24hv fix. With restrict_base_path: True (the default), the current filename.startswith(base) containment check does not enforce a directory boundary. As a result, a markdown snippet directive can read files from sibling paths that share the same prefix as base_path, such as docs vs docs_internal.

The regression was introduced in PR #2039 / commit 7c13bda5b7793b172efd1abb6712e156a83fe07d, which replaced the original directory-identity check with a plain string-prefix comparison.

Details

The regression was introduced in commit 7c13bda5b7793b172efd1abb6712e156a83fe07d (2023-05-15, #2039 *"Fix regression of snippets nested deeply under specified base path"*), which relaxed the original os.path.samefile(base, os.path.dirname(filename)) check to a plain startswith(base).

SnippetPreprocessor.get_snippet_path() in pymdownx/snippets.py:

python
if self.restrict_base_path:
    filename = os.path.abspath(os.path.join(base, path))
# If the absolute path is no longer under the specified base path, reject the file
    if not filename.startswith(base):
        continue

base is os.path.abspath(b) and has no trailing separator. str.startswith(base) is True for any filename whose string representation begins with the same characters as base, regardless of whether those characters end at a directory boundary.

Concrete example:

  • base = "/x/docs"
  • path = "../docs_secret/leak.txt" (inside the markdown snippet directive)
  • os.path.join(base, path) → "/x/docs/../docs_secret/leak.txt"
  • os.path.abspath(...) → "/x/docs_secret/leak.txt"
  • filename.startswith(base) → True, because "/x/docs_secret/..." begins with the literal string "/x/docs".

All releases from 10.0.1 (2023-05-15) through 10.21.2 (current) are affected.

Impact

Arbitrary file read within the host the build runs on, bounded by the prefix match. With base_path = /x/docs the attacker can read files from any sibling directory whose path begins with the literal string /x/docs followed by any non-separator character - for example /x/docs_internal/, /x/docs.bak/, /x/docs2/.

The threat model is the same as the original CVE-2023-32309: markdown content processed by the snippets preprocessor in a build pipeline (typical scenario: an MkDocs documentation site built in CI from PR contributions or otherwise less-trusted markdown) can read files outside the configured base. CI builds that publish the generated HTML expose the read file to the public; CI builds with secrets on disk leak those secrets.

Reproduction

Minimal local PoC, non-destructive:

python
import os, shutil, tempfile, markdown

work = tempfile.mkdtemp(prefix="pmx_poc_")
try:
    base    = os.path.join(work, "docs")
    sibling = os.path.join(work, "docs_secret")
    os.makedirs(base)
    os.makedirs(sibling)
    with open(os.path.join(sibling, "leak.txt"), "w") as f:
        f.write("TOP_SECRET_FROM_SIBLING_DIR\n")

    out = markdown.markdown(
        '--8<-- "../docs_secret/leak.txt"\n',
        extensions=["pymdownx.snippets"],
        extension_configs={
            "pymdownx.snippets": {
                "base_path": [base],
                "restrict_base_path": True,
                "check_paths": True,
            }
        },
    )
    print(out)
# -> <p>TOP_SECRET_FROM_SIBLING_DIR</p>
finally:
    shutil.rmtree(work)

Default restrict_base_path: True is sufficient - no non-default option is required.

Suggested fix

Minimal change - require the separator after the base prefix:

diff
-                        if not filename.startswith(base):
+
# Append `os.sep` so a sibling directory whose name shares a prefix
+
# (e.g. `/x/docs` vs `/x/docs_evil`) cannot satisfy the check.
+                        if not filename.startswith(base + os.sep):
                             continue

This preserves the original intent (allow snippets nested at any depth under base_path) while restoring the directory-boundary check. It does not affect the os.path.isdir(base) branch where base is a file (that branch still uses os.path.samefile).

Alternative: os.path.commonpath([base, filename]) == base is equivalent and slightly more idiomatic, though it raises ValueError on different drives on Windows and would need a try/except. The startswith(base + os.sep) fix is the smaller diff.

Note: this fix does not change behaviour for symlinks inside base_path. The existing implementation uses os.path.abspath (not os.path.realpath), so a symlink within base_path pointing outside is still followed. That is a separate concern - symlinks require write access to base_path, a much higher bar than the current bypass - and matches the behaviour the CVE-2023 fix established.

Regression test

A regression test class TestSnippetsSiblingPrefix was added in tests/test_extensions/test_snippets.py. It uses tests/test_extensions/_snippets/nested as base_path and a new fixture directory tests/test_extensions/_snippets/nested_sibling_evil/leak.txt. It asserts that the markdown directive --8<-- "../nested_sibling_evil/leak.txt" raises SnippetMissingError.

  • Without fix: test fails (AssertionError: SnippetMissingError not raised, sibling file is silently read).
  • With fix: test passes.

Full suite: python -m pytest tests/ -q → 738 passed (737 baseline + 1 new regression test). No regressions.

Affected versions

>= 10.0.1, <= 10.21.2

Threat Intelligence Overview

EPSS Score
0.0%
Top 91% exploitable
Threat Intel
1
1 source
Data Quality
7 sources
Confidence: High
EUVD NVD CVE.org EPSS GHSA Vendor GitHub VulDB

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity MEDIUM
CISA KEV No
Public POC No
EPSS 0.0%
Patch available Yes
Active threat No
Deciding rule
MEDIUM severity (CVSS 4.0-6.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Scheduled
Exploitation· derived
None
System Exposure· derived
Open
Automatable· derived
No
Human Impact· derived
Medium

Priority Score

22
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +22
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

Path traversal exploits occur when applications use user-controlled input to construct file system paths without proper validation.

More in Python

View all
CVE-2025-24016 CRITICAL POC
9.9 Feb 10

Wazuh SIEM platform versions 4.4.0 through 4.9.0 contain an unsafe deserialization vulnerability in the DistributedAPI t

CVE-2025-27520 CRITICAL POC
9.8 Apr 04

BentoML version 1.4.2 and earlier contains an unauthenticated remote code execution vulnerability through insecure deser

CVE-2025-2945 CRITICAL POC
9.9 Apr 03

pgAdmin 4 contains critical remote code execution vulnerabilities in the Query Tool download and Cloud Deployment endpoi

CVE-2013-5093 MEDIUM POC
6.8 Sep 27

The renderLocalView function in render/views.py in graphite-web in Graphite 0.9.5 through 0.9.10 uses the pickle Python

CVE-2025-32375 CRITICAL POC
9.8 Apr 09

BentoML is a Python library for building online serving systems optimized for AI apps and model inference. Rated critica

CVE-2014-0224 HIGH POC
7.4 Jun 05

OpenSSL before 0.9.8za, 1.0.0 before 1.0.0m, and 1.0.1 before 1.0.1h does not properly restrict processing of ChangeCiph

CVE-2024-21644 HIGH POC
7.5 Jan 08

pyLoad download manager version prior to 0.5.0b3.dev77 exposes the Flask SECRET_KEY through an unauthenticated endpoint.

CVE-2026-33017 CRITICAL POC
9.3 Mar 17

Langflow (a visual LLM pipeline builder) contains a critical unauthenticated code execution vulnerability (CVE-2026-3301

CVE-2017-9462 HIGH POC
8.8 Jun 06

In Mercurial before 4.1.3, "hg serve --stdio" allows remote authenticated users to launch the Python debugger, and conse

CVE-2026-49869 CRITICAL POC
10.0 Jun 26

Unauthenticated remote code execution affects Kestra OSS (the open-source event-driven orchestration platform) prior to

CVE-2026-39987 CRITICAL POC
9.3 Apr 08

Unauthenticated remote code execution in Marimo ≤0.20.4 allows attackers to execute arbitrary system commands via the `/

CVE-2024-21645 MEDIUM POC
5.3 Jan 08

pyLoad is the free and open-source Download Manager written in pure Python. Rated medium severity (CVSS 5.3), this vulne

Vendor StatusVendor

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy