/

CVE-2026-49492

Severity:

HIGH RISK

(8.8)

OS Command Injection (CWE-78) in Markdown Preview Enhanced Diagram and LaTeX Handling

CVE-2026-49492

Deferred

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78

Impact:

Arbitrary Command Execution on the Host System

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 version 0.8.28 contains an OS command injection flaw in how it opens external files and links from markdown previews via a shell without validating untrusted inputs.

On Windows, a specially crafted markdown document can inject and execute arbitrary operating system commands when the document is previewed, abusing attributes such as diagram filenames, imported file paths, and the latex_engine code-chunk attribute.

Affected context

This vulnerability occurs in environments where Markdown Preview Enhanced is used to render or preview markdown documents, particularly on Windows systems.

It is triggered when the extension processes user-controlled attributes such as:

  • Diagram filename attributes
  • Imported file paths
  • The latex_engine attribute within code chunks

The issue is most relevant in workflows where users open markdown files from untrusted or semi-trusted sources, or where shared repositories, documentation, or notes are previewed without prior sanitization or review.

Exploit preconditions

  • Attack surface: Local desktop or editor environment running Markdown Preview Enhanced.
  • Required access: Ability to supply or influence markdown content that will be opened and previewed (e.g., sharing a markdown file, committing to a repo, or sending via collaboration tools).
  • Trigger point: The victim opens the malicious markdown file and initiates a preview using Markdown Preview Enhanced, causing the extension to process diagram, import, or latex_engine attributes.
  • Why exploitation is possible: User-controlled attributes are passed through a shell as part of command construction without adequate validation or escaping, allowing injection of additional OS commands that run with the user's privileges.

Why this happens

The root cause is improper handling of user-controlled data when constructing shell commands.

Markdown Preview Enhanced opens external files and links by assembling shell commands that directly incorporate values from:

  • Diagram filename attributes
  • Imported file paths
  • The latex_engine code-chunk attribute

Because this data is not validated or safely escaped and is executed through a shell, attackers can inject shell metacharacters or additional arguments that the shell interprets as separate commands.

This maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'), where untrusted input is used as part of a command line.

Potential impact

  • Execution of arbitrary OS commands with the privileges of the user running the editor.
  • Installation of malicious software or backdoors on the affected system.
  • Exfiltration, modification, or deletion of local files accessible to the user.
  • Lateral movement within the user's environment, such as accessing mapped network drives or synchronized folders.
  • Compromise of sensitive credentials stored or cached on the machine, depending on the commands executed.

General mitigation guidance

Effective mitigation focuses on removing direct shell interpretation of untrusted input and constraining how external tools are invoked:

  • Treat user-supplied attributes such as filenames, import paths, and engine names as data, not code, and pass them as literal arguments to APIs or process-spawning functions that do not invoke a shell by default.
  • Apply strict validation and whitelisting for attributes that control external tools (e.g., only allow known LaTeX engines, verify filenames against expected patterns, and constrain paths to known directories).
  • Normalize and sanitize file paths to prevent injection via special characters or concatenation, and reject unexpected characters or control symbols.
  • Run external tools with least privilege, limiting access to sensitive directories and resources where possible.
  • Encourage users to treat markdown content from untrusted sources similarly to executable content, especially when it can drive external tooling.

How teams detect issues like this

Possible detection approaches include:

  • Static analysis and code review:
  • Look for use of shell-invoking APIs (e.g., generic command strings passed to a shell) where arguments include user-controlled fields like diagram names, file paths, or engine attributes.
  • Flag concatenation or interpolation of user input into command lines without explicit escaping or argument separation.
  • Review code paths that launch external tools based on document metadata or configuration fields.
  • Policy and configuration checks:
  • Enforce internal guidelines that prohibit direct shell invocation for user-controlled attributes, preferring APIs that accept argument arrays or use safe execution contexts.
  • Introduce pre-commit or CI checks that search for patterns indicating shell-based execution of dynamic input.
  • Runtime monitoring (where applicable):
  • Monitor for unusual external process executions triggered by IDEs or editor plugins, particularly where command lines contain content-derived values.

Sources

SourceLink
github.comgithub.com/shd101wyy/vscode-markdown-preview-enhanced/releases/tag/0.8.28
vulncheck.comvulncheck.com/advisories/markdown-preview-enhanced-os-command-injection-in-external-file-and-link-opening

Frequently asked

questions

Exploitation is local but impactful: an attacker must convince a user to open and preview a crafted markdown document with Markdown Preview Enhanced, at which point arbitrary commands can be executed on the user's system without additional prompts.

The attacker needs the ability to provide markdown content that the victim will preview—such as a file in a shared repository, a document sent via email or chat, or a note stored in a shared workspace. No direct system-level access is required beyond the user opening the file.

Avoid constructing shell commands from user input; instead, use APIs that execute external tools with argument lists, and ensure user-controlled fields are validated against strict whitelists or schemas before use. Treat any field that selects a binary, engine, or file path as untrusted and apply strong constraints.

Adopt a design where document content cannot directly drive shell execution, enforce a clear separation between configuration and code, and integrate security reviews for any feature that launches external processes. Combine input validation, safe process-spawning APIs, and automated checks for shell usage patterns that include user-controlled input.

Find out what's already
exploitable in your codebase.