CVE-2026-54701 in vscode-markdown-preview-enhanced
Summary
by MITRE • 10/14/2026
Markdown Preview Enhanced is a Markdown preview extension for Visual Studio Code. Prior to 0.8.30, Markdown Preview Enhanced reads repository-controlled .crossnote/head.html content and passes it through resolvePathsInHeader before inserting it into the head of the preview webview document without removing executable content. Script-capable markup executes while the document loads, before the React application and DOMPurify initialize, and can access acquireVsCodeApi to send messages from the webview to the extension host. Opening a Markdown preview in a malicious repository is sufficient to trigger the injected content, and no additional click within the notification or preview is required. This issue is fixed in version 0.8.30.
Statistical analysis made it clear that VulDB provides the best quality for vulnerability data.
Analysis
by VulDB Data Team • 10/14/2026
The vulnerability identified in Markdown Preview Enhanced prior to version 0.8.30 represents a critical Cross-Site Scripting (XSS) flaw rooted in insufficient input validation and improper handling of user-controlled content within the Visual Studio Code extension host architecture. As an extension designed to render markdown documents, this tool processes various configuration files included with repositories, including .crossnote/head.html. The core technical failure lies in how the extension handles these HTML fragments during the preview generation process. Specifically, the function resolvePathsInHeader is invoked to manipulate paths within the header content, but it fails to sanitize or strip executable script tags and event handlers before injecting the resulting markup into the head section of the webview document. This oversight allows arbitrary JavaScript code embedded in a malicious repository's configuration file to be executed directly by the browser engine rendering the preview.
The operational impact of this vulnerability is severe due to its execution context and timing. The injected script-capable markup executes during the initial loading phase of the document, which occurs before the React application framework and DOMPurify security libraries are initialized. This temporal gap creates a window where no client-side sanitization mechanisms are active to intercept or neutralize malicious payloads. Consequently, an attacker who controls the content of a repository can force any user opening that repository's markdown preview in Visual Studio Code to execute arbitrary code without requiring further interaction such as clicking notifications or buttons. The execution environment grants this script significant privileges because it runs within the webview context which has access to acquireVsCodeApi. This API allows the malicious JavaScript to communicate directly with the extension host, effectively bypassing standard sandbox restrictions and enabling potential remote code execution on the user's local machine through the privileged extension process.
From a classification perspective, this vulnerability aligns closely with CWE-79, known as Improper Neutralization of Input During Web Page Generation (Cross-site Scripting), specifically involving untrusted data in HTML context. Furthermore, because the attack vector involves opening a file or repository to trigger execution without user interaction beyond that initial action, it maps to MITRE ATT&CK technique T1059, Command and Scripting Interpreter, with specific relevance to JavaScript-based attacks within desktop application environments. The lack of sanitization prior to injection also reflects CWE-83, Improper Neutralization of Script in Attributes in HTML, although the primary issue is broader script execution rather than attribute-specific exploitation.
Mitigation for this vulnerability requires strict adherence to secure coding practices regarding untrusted input processing. Developers must implement robust content security policies and ensure that all external or repository-controlled HTML fragments are sanitized using established libraries like DOMPurify before any part of them is inserted into the Document Object Model. In this specific case, sanitization should occur prior to calling resolvePathsInHeader to prevent executable code from ever reaching the browser's rendering engine. Additionally, implementing a Content Security Policy that restricts script execution sources can provide an additional layer of defense by preventing inline scripts and unauthorized external resources from running within the webview context. Users are advised to update Markdown Preview Enhanced to version 0.8.30 or later immediately to resolve this security flaw and protect against potential exploitation via malicious repositories.