CVE-2018-5773: markdown2 - Cross-Site Scripting Vulnerability

markdown2 Updated 02 Oct 2025

Summary

12/07/2018
Yes i
Moderate
6.1

CVE-2018-5773: markdown2 is vulnerable to cross-site scripting. Affects markdown2 versions < 2.3.6. Fixed in 2.3.6. How to fix ↓

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

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

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

markdown2 is a Python package that converts Markdown text into HTML. It provides a simple and convenient way to format and display text on websites or in other applications. However, versions up to 2.3.5 of markdown2 are vulnerable to a cross-site scripting (XSS) attack.

Vulnerability Detail

The safe_mode feature in markdown2, which is designed to sanitize user input and prevent XSS attacks, is flawed and does not properly escape input. This allows an attacker to craft a payload that can trigger XSS by omitting the final > character from an IMG tag. This vulnerability can lead to the execution of malicious scripts in the context of the affected user's browser, potentially compromising their sensitive information or performing unauthorized actions.

How To Fix

Latest published version: 2.5.5 as of 23 Oct 2026

pip install --upgrade "markdown2==2.5.5"

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

If you need the minimum change

2.3.6

This is the first release that contains the fix.

pip install --upgrade "markdown2==2.3.6"

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

Workaround

If upgrading to the latest version is not immediately possible, a temporary workaround is to disable the safe_mode feature in markdown2. However, this may leave your application vulnerable to other XSS attacks. To disable safe_mode, you can modify the code where markdown2 is used and set the safe_mode parameter to False. For example:

text = '...'  # Markdown text
html = markdown2.markdown(text, safe_mode=False)

Conclusion

The markdown2 package up to version 2.3.5 is vulnerable to a cross-site scripting (XSS) attack due to a flaw in the safe_mode feature. Upgrading to version 2.3.6 or later is the recommended solution to fix this vulnerability. If immediate upgrade is not possible, disabling safe_mode can serve as a temporary workaround. For further assistance or support in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for markdown2 →

Share this vulnerability

FAQ

markdown2 is a Python package that converts Markdown text into HTML. It is commonly used in web applications to format and display user-generated content.

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 unauthorized actions.

The markdown2 XSS vulnerability occurs due to a flaw in the safe_mode feature, which fails to properly escape user input. By crafting a payload that omits the final > character from an IMG tag, an attacker can trigger XSS and execute malicious scripts in the context of the affected user's browser.

Exploiting this vulnerability can allow an attacker to steal sensitive information, such as login credentials or personal data, from users who view the compromised content. It can also enable the attacker to perform unauthorized actions on behalf of the user, potentially leading to further compromise or damage.

To protect your application, it is recommended to upgrade markdown2 to version 2.3.6 or later, which includes a fix for the XSS vulnerability. Additionally, ensure that user-generated content is properly sanitized and validated to prevent the injection of malicious scripts.

Related vulnerabilities

Recent vulnerabilities recorded for markdown2.

How To Fix

Latest published version: 2.5.5 as of 23 Oct 2026

pip install --upgrade "markdown2==2.5.5"

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

If you need the minimum change

2.3.6

This is the first release that contains the fix.

pip install --upgrade "markdown2==2.3.6"

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