The vulnerability exists in the ui.interactive_image component of NiceGUI, where SVG content was rendered without sanitization, leading to a Cross-Site Scripting (XSS) issue. The root cause was the use of Vue's v-html directive in the frontend, which renders raw HTML. An attacker could provide a malicious SVG payload containing <foreignObject> with embedded scripts.
The analysis of the patch commit 58ad0b36e19922de16bbc79ea3ddd29851b1a3e3 reveals that the fix involves introducing a sanitize parameter to the InteractiveImage and InteractiveImageLayer components. The key vulnerable functions are the constructors (__init__) for these classes, as they are the primary entry points for the unsanitized content. Additionally, the add_layer method of InteractiveImage was vulnerable as it created new layers without ensuring their content would be sanitized.
The patch addresses the vulnerability by adding a _handle_content_change method that applies a sanitization function to the content before it is sent to the frontend. By default, if content is provided without an explicit sanitize option, a warning is issued. This change ensures that developers are aware of the potential security risk and must explicitly choose to disable sanitization if needed.