The vulnerability is a Cross-Site Scripting (XSS) issue within the ui.sub_pages feature of NiceGUI. The root cause is the improper handling of user-controlled parts of the URL, specifically the URL fragment and path, when generating JavaScript code on the server-side to be executed on the client.
The primary vulnerability, as detailed in the advisory, exists in the SubPages._scroll_to_fragment method. This method takes a URL fragment and uses it to construct a JavaScript snippet to scroll to a specific element. The fragment is not sanitized, allowing an attacker to inject arbitrary JavaScript by crafting a malicious URL fragment. The SubPages._handle_scrolling method is the entry point for this vulnerability, as it reads the fragment from the URL and passes it to _scroll_to_fragment.
A similar vulnerability was patched in the same release within the SubPagesRouter._handle_navigate method. This function used the current path to generate a JavaScript call to history.pushState without sanitization, creating another XSS vector through a malicious path.
The patches for both issues involve using json.dumps to properly escape the fragment and path strings before they are embedded into the JavaScript code, preventing the injection of malicious scripts. Any runtime profile during exploitation would show calls to SubPages._handle_scrolling and SubPages._scroll_to_fragment for the fragment-based XSS, or SubPagesRouter._handle_navigate for the path-based XSS.