/

CVE-2026-11422

Severity:

HIGH RISK

(7.1)

JavaScript Code Injection (CWE-95) in Markdown Preview Enhanced WaveDrom Renderer

CVE-2026-11422

Awaiting Analysis

Vulnerability type

Category:

Code Injection

CWE:

CWE-95

Impact:

Arbitrary Code Execution in VS Code Webview and Local File Manipulation

Severity:

HIGH RISK

(7.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Markdown Preview Enhanced with the crossnote engine contains a JavaScript code injection flaw in its WaveDrom rendering pipeline that allows arbitrary script execution inside the VS Code webview.

When a crafted Markdown document includes a malicious wavedrom fenced code block, its contents are passed unsafely into window.eval(), enabling attackers to run JavaScript that can abuse extension messaging and trigger arbitrary file writes on the local filesystem.

Affected context

The vulnerability appears in environments where:

  • The Markdown Preview Enhanced extension is installed (0.8.x) with crossnote engine 0.9.28
  • WaveDrom fenced code blocks are rendered within the VS Code webview
  • Markdown content may originate from untrusted or shared sources (e.g., cloned repositories, documentation, notes)

The risk is specific to the WaveDrom rendering path that interprets fenced wavedrom code blocks and evaluates them in the browser-like webview context.

Exploit preconditions

  • Attack surface: Opening or previewing a malicious Markdown file in VS Code with Markdown Preview Enhanced enabled.
  • Required access: Ability to introduce or modify Markdown documents rendered by the extension (e.g., committing to a repo, sharing project files, or editing shared notes).
  • Trigger point: User opens the Markdown file and activates the preview (automatic or manual) that processes the WaveDrom fenced code block.
  • Why exploitation is possible: The WaveDrom block's content is passed directly to window.eval() without sanitization or sufficient validation, allowing attacker-controlled JavaScript to execute inside the webview. That script can interact with the extension's message-passing mechanisms to initiate arbitrary file writes.

Why this happens

The core issue is a classic code injection pattern: treating attacker-controlled text as executable code.

In the WaveDrom rendering pipeline, the extension forwards the raw content of a wavedrom fenced block to window.eval() in the webview. This effectively grants the author of the Markdown document the ability to inject arbitrary JavaScript into the preview context. Because the webview can communicate with the extension host via message passing, this injected code can invoke filesystem-related functionality exposed by the extension, escalating from in-webview script execution to unintended local file manipulation.

Conceptually, this maps to CWE-95: Improper Neutralization of Directives in Dynamically Evaluated Code, where untrusted input is dynamically evaluated without being constrained to a safe subset or subject to robust sanitization.

Potential impact

  • Execution of arbitrary JavaScript within the VS Code webview when a crafted Markdown file is previewed
  • Abuse of extension message-passing APIs to trigger arbitrary file writes on the local filesystem
  • Overwriting or planting files in the workspace, potentially leading to:
  • Source code tampering
  • Malicious configuration changes
  • Introduction of backdoored scripts or build artifacts
  • Potential pivot to further compromise of the developer environment, depending on what the extension exposes to the webview
  • Loss of integrity and possible confidentiality of project files opened in the affected workspace

General mitigation guidance

Effective mitigation focuses on eliminating dynamic evaluation of untrusted content and tightening the interaction between the webview and the extension host:

  • Replace eval-based rendering with a deterministic WaveDrom parsing and rendering routine that interprets structured data rather than executing arbitrary JavaScript.
  • Restrict the WaveDrom syntax to a safe data-only subset (e.g., JSON-like structures) and validate input against a strict schema before processing.
  • Ensure any code paths that must interpret user-controlled content operate with a whitelist of allowed operations rather than generic execution primitives.
  • Harden webview–extension communication by:
  • Limiting message types and payloads to narrowly-scoped, well-validated commands.
  • Enforcing strict checks on what operations can be initiated from the webview, especially those touching the filesystem.
  • Apply least-privilege principles to file operations initiated by the extension, constraining writes to intended directories and file types.
  • Consider providing security-focused configuration options that disable or strictly limit execution-like features in Markdown previews when handling untrusted documents.

How teams detect issues like this

Detection can leverage both code-centric and workflow-centric controls:

  • Static analysis and code scanning:
  • Flag usage of eval, Function, or equivalent dynamic execution constructs in extension code, especially when fed by document content or webview messages.
  • Identify webview scripts that process fenced code blocks and check for direct evaluation or unvalidated concatenation into executable contexts.
  • Code review practices:
  • Review any rendering pipelines that transform Markdown fenced blocks into executable JavaScript or complex logic.
  • Inspect webview message handlers for filesystem operations triggered by loosely validated or generic commands from the UI layer.
  • Policy enforcement:
  • Enforce extension development guidelines that prohibit dynamic evaluation of user-supplied content.
  • Integrate automated checks in CI/CD for sensitive APIs and patterns (e.g., regex or linter rules for eval and similar constructs).
  • Runtime and behavioral monitoring (where applicable):
  • Monitor for unusual file write patterns originating from the extension's process when opening or previewing Markdown files from untrusted locations.

Sources

SourceLink
github.comgithub.com/shd101wyy/crossnote/commit/5588ca2121c3da43fe331575dc5cf4ef347b91ee
github.comgithub.com/shd101wyy/vscode-markdown-preview-enhanced/commit/dcd80281c986293b93d9f1af34ced64dcb230c77
github.comgithub.com/shd101wyy/vscode-markdown-preview-enhanced/issues/2315
vulncheck.comvulncheck.com/advisories/markdown-preview-enhanced-x-code-injection-via-wavedrom-rendering

Frequently asked

questions

It can be exploited by getting a user to open and preview a malicious Markdown document in VS Code with the vulnerable extension enabled. The attacker does not need direct access to the victim's machine, but must deliver a crafted file or repository that the victim opens.

The attacker needs the ability to supply or influence Markdown content that the victim opens—such as contributing to a shared repository, sending project files, or otherwise providing documentation containing a malicious wavedrom fenced block.

Avoid dynamic evaluation of any content derived from user-controlled documents. Use structured data parsing, strict schemas, and deterministic rendering engines, and ensure that webviews cannot invoke sensitive filesystem or system operations without narrow, validated, and explicit intent.

Treat all document content as untrusted, prohibit eval and equivalent dynamic execution primitives in rendering logic, and design webview–extension APIs with least privilege and strict validation. Incorporate secure coding reviews and static checks specifically targeting content-to-code paths in preview and visualization features.

Find out what's already
exploitable in your codebase.