CVE-2017-16876: mistune Cross-site scripting (XSS) vulnerability

mistune Updated 02 Oct 2025

Summary

04/01/2019
Yes i
Moderate
6.1

CVE-2017-16876: mistune Cross-site scripting (XSS) vulnerability. Affects mistune versions < 0.8.1. Fixed in 0.8.1. How to fix ↓

Also tracked for

The same CVE-2017-16876 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

Mistune is a Python package available on PyPI that provides a fast and full-featured Markdown parser. It is commonly used in web applications to parse and render Markdown content. The mistune package is vulnerable to a cross-site scripting (XSS) attack due to a failure to properly escape the 'key' argument in the _keyify function in mistune.py. This vulnerability allows remote attackers to inject arbitrary web script or HTML into the rendered output.

Vulnerability Detail

The mistune package before version 0.8.1 is affected by a cross-site scripting (XSS) vulnerability. The vulnerability originates from the _keyify function in mistune.py, which fails to properly escape the 'key' argument. This allows an attacker to inject malicious web script or HTML into the rendered output, potentially leading to the execution of arbitrary code or the theft of sensitive information. The impact of this vulnerability can range from defacement of web pages to the compromise of user accounts and the exfiltration of confidential data.

How To Fix

Latest published version: 3.4.0 as of 22 Oct 2026

pip install --upgrade "mistune==3.4.0"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

0.8.1

This is the first release that contains the fix.

pip install --upgrade "mistune==0.8.1"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

There is no known workaround for this vulnerability. It is essential to upgrade to the fixed version of mistune to mitigate the risk of XSS attacks.

Conclusion

The mistune package is vulnerable to a cross-site scripting (XSS) attack due to a failure to properly escape the 'key' argument in the _keyify function. To mitigate this vulnerability, it is essential to upgrade to mistune version 0.8.1 or later. This will ensure that the 'key' argument is properly escaped, preventing the injection of malicious web script or HTML. For further assistance or support in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for mistune →

Share this vulnerability

FAQ

Mistune is a Python package that provides a Markdown parser and renderer. It is commonly used in web applications to convert Markdown content into HTML.

Cross-site scripting (XSS) is a type of security vulnerability that allows attackers to inject malicious scripts into web pages viewed by other users. This can lead to the theft of sensitive information or the execution of arbitrary code.

The mistune XSS vulnerability is caused by a failure to properly escape the 'key' argument in the _keyify function. This allows an attacker to inject malicious web script or HTML into the rendered output, potentially leading to the execution of arbitrary code or the theft of sensitive information.

The impact of the mistune XSS vulnerability can range from defacement of web pages to the compromise of user accounts and the exfiltration of confidential data. Attackers can exploit this vulnerability to inject malicious scripts or HTML into the rendered output, affecting any user who views the affected content.

To protect your application from the mistune XSS vulnerability, it is crucial to upgrade to mistune version 0.8.1 or later. This version includes a fix for the XSS vulnerability. Additionally, it is recommended to regularly update your dependencies and follow secure coding practices to minimize the risk of XSS attacks.

Related vulnerabilities

Recent vulnerabilities recorded for mistune.

How To Fix

Latest published version: 3.4.0 as of 22 Oct 2026

pip install --upgrade "mistune==3.4.0"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

0.8.1

This is the first release that contains the fix.

pip install --upgrade "mistune==0.8.1"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback