Executive brief
Typora is a popular Markdown editor that renders diagrams using the Mermaid engine. A critical vulnerability allows attackers to inject arbitrary HTML and JavaScript code through malicious Mermaid diagram definitions, leading to complete remote code execution on the user's system when they open a crafted Markdown file—no user interaction beyond file opening is required.
Technical details
The vulnerability is an HTML injection leading to remote code execution in Typora's Mermaid rendering engine. The root cause combines three flaws: (1) Mermaid's lexer uses permissive regex patterns that allow `<>` characters in classDef/style values without filtering, (2) Mermaid concatenates these unescaped values into a `<style>` tag via innerHTML without HTML-escaping, allowing attackers to inject `</style>` and subsequent HTML tags, and (3) Typora configures Mermaid with `securityLevel:"loose"`, which disables final DOMPurify sanitization. An attacker can inject an `<img onerror>` handler or similar to execute arbitrary JavaScript. Since Typora exposes Node.js `require` to the renderer process, attackers can invoke `child_process` to execute system commands. The attack is triggered automatically when a victim opens a malicious `.md` file containing the exploit payload in any vulnerable Mermaid diagram type (stateDiagram-v2, classDiagram, etc.). Versions up to 1.13.8/1.14.6 are affected; upgrading to 1.14.8 or later resolves the issue.
Affected products
- Typora Typora up to 1.13.8/1.14.6
Timeline
- 2026-08-31: disclosed
- 2026: patched: Fixed in version 1.14.8