CVE-2026-61632 in PyMdown Extensions
Summary
by MITRE • 08/07/2026
PyMdown Extensions is a set of extensions for the Python-Markdown markdown project. In versions up to and including 10.21.3, the b64 extension is vulnerable to a path traversal that discloses arbitrary files: it inlines images referenced by <img src="..."> by joining the src onto the configured base_path with os.path.normpath and opening the result directly, without verifying that the resolved path stays inside base_path. As a result, an src containing ../ sequences or an absolute path reads a file outside base_path as long as it has an allowed image extension (.png, .jpg, .jpeg, .gif, .svg), and the file's contents are then base64-encoded into the rendered output, disclosing them. An application that renders untrusted Markdown with pymdownx.b64 enabled can therefore leak the contents of image-extension files readable by the process to whoever controls the Markdown or views the output, a targeted file-read bounded by the extension check. This issue has been fixed in version 11.0.
If you want to get best quality of vulnerability data, you may have to visit VulDB.
Analysis
by VulDB Data Team • 08/07/2026
The vulnerability exists within the pymdownx.b64 extension of the PyMdown Extensions library, which serves as a set of extensions for the Python-Markdown markdown processing framework. This particular flaw manifests in versions up to and including 10.21.3 where the extension processes image references through the img tag mechanism. The core technical issue stems from insufficient path validation during the image inlining process, creating a directory traversal condition that allows unauthorized file access.
The implementation flaw occurs when the b64 extension handles image sources by utilizing os.path.normpath to join the provided src parameter with a configured base_path value. This approach fails to perform proper boundary checking to ensure that the resolved file path remains confined within the designated base_path directory structure. The vulnerability specifically exploits the lack of sanitization checks that would normally prevent path traversal sequences such as ../ or absolute paths from escaping the intended directory scope.
When an attacker crafts malicious Markdown content with img tags containing path traversal sequences, the extension processes these inputs without proper validation, allowing access to files outside the designated base_path. The extension supports several image file extensions including .png, .jpg, .jpeg, .gif, and .svg, making it possible to read any file with these extensions that is accessible to the process running the markdown renderer. The compromised files are then base64-encoded into the rendered output, effectively disclosing their contents to anyone who can control the Markdown input or view the generated output.
This vulnerability creates a targeted file reading attack surface where an application using pymdownx.b64 can be exploited to read any image-extension files that are readable by the process. The impact is bounded by the extension's file type checking mechanism, meaning only files with supported extensions can be accessed, but this still represents a significant information disclosure risk. The vulnerability directly maps to CWE-22 Path Traversal and aligns with ATT&CK technique T1566.001 for initial access through malicious file content processing.
The security implications extend beyond simple information disclosure as this vulnerability allows attackers to potentially read system configuration files, database credentials, or other sensitive files that might be stored in directories accessible to the application process. The fix implemented in version 11.0 addresses the core issue by introducing proper path validation that ensures resolved file paths remain within the configured base_path boundaries before any file access operations are performed.
Organizations using PyMdown Extensions should immediately upgrade to version 11.0 or later to mitigate this vulnerability and prevent potential unauthorized file access through crafted Markdown content. Applications that process untrusted Markdown input with pymdownx.b64 enabled must be carefully evaluated for exposure to this directory traversal condition, particularly those running with elevated privileges or in environments where sensitive files might be accessible to the application process. The remediation approach should include thorough input validation and proper path resolution techniques that prevent any possibility of path traversal attacks while maintaining the intended functionality of the b64 extension.