CVE-2025-66469: NiceGUI Reflected XSS via Style Injection in Dynamic CSS Functions
Summary
CVE-2025-66469: NiceGUI Reflected XSS in ui.add_css, ui.add_scss, and ui.add_sass via Style Injection. Affects nicegui versions < 3.4.0. Fixed in 3.4.0. How to fix ↓
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.
No signup required · Results in about 60 seconds
Background
NiceGUI is a Python library that simplifies the creation of user interfaces for web applications. It allows developers to build interactive applications with ease, utilizing features such as dynamic theming and custom styles. However, certain functions within NiceGUI, specifically ui.add_css, ui.add_scss, and ui.add_sass, have been found to be vulnerable to Cross-Site Scripting (XSS) attacks due to improper input sanitization.
Vulnerability Detail
A Cross-Site Scripting (XSS) vulnerability exists in the ui.add_css, ui.add_scss, and ui.add_sass functions in NiceGUI (v3.3.1 and earlier). These functions allow developers to inject styles dynamically but lack proper sanitization for the JavaScript context they generate. An attacker can exploit this by injecting closing tags (e.g., </style> or </script>), leading to the execution of arbitrary JavaScript. This vulnerability can be exploited when user input is directly used in these functions without validation, potentially compromising user data and application integrity.
How To Fix
Latest published version: 3.18.0 as of 22 Oct 2026
pip install --upgrade "nicegui==3.18.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
3.4.0
This is the first release that contains the fix.
pip install --upgrade "nicegui==3.4.0"
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
As a temporary workaround, avoid using untrusted input directly in the ui.add_css, ui.add_scss, or ui.add_sass functions. Instead, validate and sanitize any user input before using it in these functions. For example:
from nicegui import ui
@ui.page('/')
def main(color: str = 'blue'):
# Ensure the color is a safe value
safe_color = color if color in ['red', 'blue', 'green'] else 'blue'
ui.add_css(f'.q-btn {{ background-color: {safe_color} !important; }}')
ui.button('Click Me')
ui.run(port=8082)
Conclusion
The vulnerability identified as CVE-2025-66469 in NiceGUI poses a significant risk due to its potential for XSS attacks through dynamic style injection. Developers are urged to update to the patched version 3.4.0 or later and implement input validation to safeguard their applications.
See every vulnerability recorded for nicegui →
FAQ
The vulnerability is a reflected Cross-Site Scripting (XSS) issue that allows attackers to inject arbitrary JavaScript into web applications using NiceGUI.
Versions of NiceGUI up to and including 3.3.1 are affected by this vulnerability.
You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.
The CVSS score of this vulnerability is 6.1, indicating a moderate severity level.
If immediate updates are not possible, implement input validation and sanitization as a temporary workaround to mitigate the risk of exploitation.
References
Related vulnerabilities
Recent vulnerabilities recorded for nicegui.