CVE-2026-25516·Python vulnerability
NiceGUI is a Python-based UI framework. The ui.markdown() component uses the markdown2 library to convert markdown content to HTML, which is then rendered via innerHTML. By default, markdown2 allows raw HTML to pass through unchanged. This means that if an application renders user-controlled content through ui.markdown(), an attacker can inject malicious HTML containing JavaScript event handlers. Unlike other NiceGUI components that render HTML (ui.html(), ui.chat_message(), ui.interactive_image()), the ui.markdown() component does not provide or require a sanitize parameter, leaving applications vulnerable to XSS attacks. This vulnerability is fixed in 3.7.0.
- Severity
- medium
- Software
- Python
- Fixed in
- 3.7.0
- Published
How likely is exploitation
FIRST's Exploit Prediction Scoring System puts the probability of this CVE being exploited in the next 30 days at 0.24% — higher than 15% of all published CVEs. EPSS is an independent forecast of exploitation, not a severity rating: it says nothing about how much damage a successful attack does, which is what a CVSS score measures.
Affected versions
Until: 3.7.0
Fixed in: 3.7.0
How to fix this CVE
Update NiceGUI to version 3.7.0 or later to resolve the XSS vulnerability in the ui.markdown() component. The vulnerability allows attackers to inject malicious HTML and JavaScript through markdown content when user input is rendered without sanitization. Ensure all Python environments running NiceGUI applications are patched immediately, especially those processing untrusted markdown content from end users.
sudo dnf update python3-niceguiDefensia detects this vulnerability
What an exploitation attempt looks like
Sample log line indicative of exploitation attempts:
POST requests containing markdown payloads with embedded HTML tags such as <img src=x onerror=alert()>, <svg onload=>, or <iframe> elements directed at ui.markdown() endpoints; browser console errors showing script execution from markdown-rendered contentWAF mitigation (if patching is not yet possible)
Add this rule to your WAF to block exploitation attempts while you schedule the patch.
Implement input validation to strip or escape HTML tags in markdown content before submission to ui.markdown() endpoints. Deploy WAF rules to block requests containing event handler attributes (onerror, onclick, onload, etc.) in markdown payloads. Consider implementing Content Security Policy (CSP) headers with script-src directives to prevent inline script execution.How to check if you are affected
- Check NiceGUI version: pip show nicegui | grep Version
- Identify markdown usage in your codebase: grep -r 'ui.markdown' /path/to/application --include='*.py'
- Review application logs for suspicious HTML/JavaScript patterns in markdown inputs: grep -i '<script\|onerror\|onclick\|onload' /var/log/application.log
- Verify the patch: pip show nicegui | grep -q 'Version: 3.7.0' && echo 'Patched' || echo 'Vulnerable'
FAQ
What is CVE-2026-25516?
This is a cross-site scripting (XSS) vulnerability in NiceGUI's ui.markdown() component that fails to sanitize HTML content before rendering it in the browser. Attackers can inject malicious JavaScript payloads through markdown content that will execute in the context of the application.
Is CVE-2026-25516 being actively exploited?
No, this vulnerability is not listed in the CISA Known Exploited Vulnerabilities (KEV) catalog and no public exploit code is currently available.
What versions of NiceGUI are affected by CVE-2026-25516?
All versions prior to 3.7.0 are affected by this vulnerability. The fix was introduced in version 3.7.0 and later.
How do I check if my server is vulnerable to CVE-2026-25516?
Run 'pip show nicegui | grep Version' to determine the installed version. If the version is below 3.7.0, your application is vulnerable. Additionally, search your code for ui.markdown() calls processing user-supplied content.
Does Defensia detect CVE-2026-25516?
Yes — Defensia's CVE advisory scanner compares installed package versions against the NVD database. If NiceGUI is installed on a monitored server, CVE-2026-25516 will appear in your dashboard with remediation steps.
Related Python CVEs
References
Track CVEs across your fleet automatically
Defensia scans your Linux servers and tells you exactly which ones are running vulnerable versions — including CVE-2026-25516. Free for 1 server.
Get started free