VYPR
High severity8.8NVD Advisory· Published Jun 5, 2026· Updated Jun 5, 2026

CVE-2026-50733

CVE-2026-50733

Description

Markdown Preview Enhanced before 0.8.28 parses WaveDrom diagrams by evaluating untrusted markdown content with eval(), allowing arbitrary JavaScript execution. The flaw affects every render path - the live preview (window.eval) and presentation mode plus HTML export (the bundled WaveDrom.ProcessAll()/eva() helpers) - and can also be triggered through a element injected via raw HTML in markdown. When a victim previews or exports a crafted markdown document, an attacker can execute arbitrary code, leading to arbitrary file write. Fixed in 0.8.28 by parsing with JSON5.parse() and sanitizing WaveDrom data scripts to inert strict JSON.

Patches

0

No patches discovered yet.

Vulnerability mechanics

Root cause

"Markdown Preview Enhanced evaluates untrusted WaveDrom diagram content with eval() instead of safe parsing, allowing arbitrary JavaScript execution."

Attack vector

An attacker can craft a markdown document containing a WaveDrom diagram with malicious JavaScript. When a victim previews or exports this document, the JavaScript is executed within the VS Code webview context. This script can then interact with the VS Code API to write arbitrary content to any file on the filesystem, as demonstrated by overwriting `~/.ssh/authorized_keys` [ref_id=1]. The vulnerability is triggered through any render path, including live preview, presentation mode, and HTML export [ref_id=1].

Affected code

The vulnerability lies in the `renderWavedrom()` function within `crossnote/src/webview/containers/preview.ts`, which calls `window.eval()` on the raw content of WaveDrom fenced code blocks. Both server-side and client-side sanitizers, specifically `crossnote/src/markdown-engine/sanitize.ts` and `crossnote/src/webview/lib/sanitize.ts`, intentionally preserve `<script type="WaveDrom">` tags. The blind command dispatch in `mpe/src/preview-provider.ts` and the `updateMarkdown()` function in `mpe/src/extension-common.ts` facilitate the arbitrary file write.

What the fix does

The fix replaces the unsafe `eval()` call with `JSON.parse()` for parsing WaveDrom diagram content. Additionally, WaveDrom data scripts are now sanitized to ensure they are inert strict JSON. This change prevents the execution of arbitrary JavaScript by ensuring that only valid JSON is processed, thereby closing the code injection vulnerability.

Preconditions

  • inputA markdown file containing a crafted WaveDrom diagram with a JavaScript payload.
  • configThe VS Code webview context must not have a Content Security Policy restricting script execution.

Reproduction

Create a file named `poc-authorized-keys.md` with the provided WaveDrom content. Open this file in VS Code and preview it. After previewing, check the `~/.ssh/authorized_keys` file to verify it has been overwritten with the attacker-controlled SSH public key [ref_id=1].

Generated on Jun 5, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

3

News mentions

0

No linked articles in our index yet.