/

CVE-2026-50733

Severity:

HIGH RISK

(8.8)

Eval Injection in WaveDrom Diagram Parsing (CWE-95) in Markdown Preview Enhanced

CVE-2026-50733

Deferred

Vulnerability type

Category:

Code Injection via Unsafe Eval

CWE:

CWE-95

Impact:

Arbitrary Code Execution leading to Arbitrary File Write

Severity:

HIGH RISK

(8.8)

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 before 0.8.28 evaluates WaveDrom diagram definitions using eval() on untrusted markdown content, allowing arbitrary JavaScript execution in all render paths.

When a user previews, presents, or exports a crafted markdown document, an attacker-controlled WaveDrom block or script can execute code, which can be chained to arbitrary file write on the victim system.

Affected context

This vulnerability occurs in environments using Markdown Preview Enhanced (prior to 0.8.28) to render markdown documents that contain WaveDrom diagrams.

Any context where markdown is rendered with:

  • Live preview
  • Presentation mode
  • HTML export

is affected, because all of these paths process WaveDrom content.

The issue manifests when WaveDrom definitions are taken directly from user-controlled markdown or from raw HTML <script type="WaveDrom"> blocks and are then evaluated using eval() or equivalent helper functions, without first constraining the input to a safe data format.

Exploit preconditions

  • Attack surface: Markdown rendering pipeline within Markdown Preview Enhanced (editor extension / application).
  • Required access: Ability to supply or influence the markdown content being opened (e.g., sharing a crafted file, repository, or snippet that a victim opens in the extension).
  • Trigger point: User opens, previews, presents, or exports the malicious markdown so that WaveDrom diagrams are rendered.
  • Why exploitation is possible: The WaveDrom data is passed to eval() (or helper functions that call eval()) directly, without restricting it to inert JSON data. This allows attacker-controlled JavaScript to run with the privileges of the rendering context, which in turn can access extension APIs or host integration that enable file system writes.

Why this happens

The root cause is the use of eval() to interpret WaveDrom diagram definitions embedded in markdown, instead of treating them as strictly structured data.

This maps to CWE-95: Improper Neutralization of Directives in Dynamically Evaluated Code ('Eval Injection'), where external input is concatenated or passed into a dynamic evaluation function.

By allowing WaveDrom blocks and <script type="WaveDrom"> elements to be evaluated directly, the implementation collapses the boundary between content and code: diagram text is treated as executable JavaScript rather than as data.

In this pattern, any attacker who can influence the markdown can inject arbitrary JavaScript that runs when the renderer processes the document, enabling further abuse such as invoking file APIs exposed by the environment.

Potential impact

  • Arbitrary JavaScript execution in the context of the Markdown Preview Enhanced renderer.
  • Arbitrary file write on the victim machine, subject to the capabilities exposed by the host application or extension environment.
  • Manipulation or exfiltration of sensitive project files opened in the same environment.
  • Tampering with exported HTML or slides (e.g., injecting backdoors into shared outputs).
  • Potential lateral movement by planting malicious files or scripts in trusted project locations.

General mitigation guidance

Effective mitigation focuses on treating diagram definitions as data, not code, and tightening the evaluation surface:

  • Replace eval()-based parsing with data-only parsers (e.g., strict JSON/JSON5 parsing) that do not execute arbitrary code.
  • Constrain WaveDrom inputs to a well-defined schema, rejecting or ignoring any constructs outside the expected diagram data format.
  • Sanitize and normalize <script type="WaveDrom"> contents to inert data structures before passing them to any rendering logic.
  • Ensure that rendering helpers (such as WaveDrom.ProcessAll()) operate purely on parsed data objects and never invoke general-purpose code evaluation on user input.
  • Run markdown rendering components with least privilege, minimizing their ability to read or write files beyond what is strictly required.
  • Treat all markdown content as untrusted, even when it originates from internal repositories, and avoid special trust assumptions for local files.

How teams detect issues like this

Detection can focus on both code-level patterns and behavioral indicators:

  • Static analysis and code review:
  • Search for uses of eval(), new Function(), or similar dynamic evaluation primitives applied to values derived from markdown or HTML content.
  • Flag any WaveDrom-related code paths that construct JavaScript snippets from strings and then execute them.
  • Enforce policies that require diagram or markup parsers to use data-only parsing APIs (e.g., JSON/JSON5) and prohibit dynamic evaluation of content.
  • Automated tooling:
  • Integrate static application security testing (SAST) rules that detect CWE-95 patterns in extensions or plugins that parse user text.
  • Use dependency or plugin audits to scan for known eval-based rendering primitives.
  • Runtime/behavioral monitoring (where applicable):
  • Instrument the environment to log unexpected file write operations initiated by rendering components.
  • Monitor for suspicious script constructs within documents that are meant to contain only diagram data.

Sources

SourceLink
github.comgithub.com/shd101wyy/vscode-markdown-preview-enhanced/issues/2315
github.comgithub.com/shd101wyy/vscode-markdown-preview-enhanced/releases/tag/0.8.28
vulncheck.comvulncheck.com/advisories/markdown-preview-enhanced-arbitrary-code-execution-via-wavedrom-eval

Frequently asked

questions

It typically requires the victim to open attacker-controlled markdown content locally (e.g., from a shared repository or file). However, from the attacker's perspective, it behaves like a remote attack because they can distribute a malicious document that executes when viewed in the vulnerable renderer.

The attacker only needs the ability to supply markdown content that the victim opens in Markdown Preview Enhanced, such as a project README, documentation file, or shared notes. No direct access to the victim's machine is required beyond convincing them to open or preview the file.

Avoid eval() and any dynamic code evaluation on user-controlled content. Parse diagram or markup definitions as strict data (e.g., via JSON/JSON5), validate them against a schema, and ensure rendering logic transforms data into visuals without ever executing arbitrary script fragments.

Design rendering pipelines under the assumption that all documents are untrusted. Use safe, data-only parsers for embedded languages, prohibit dynamic evaluation of user input, enforce security-focused code review for any feature that interprets document content, and add automated checks that flag eval usage and other CWE-95 patterns early in development.

Find out what's already
exploitable in your codebase.