The vulnerability lies in the HTML export functionality of the Pi Agent, specifically in how it processes markdown links and images. The root cause is improper sanitization of URLs provided in markdown content. The functions link and image within the markdown renderer used a weak blocklist-based approach to filter out malicious URL schemes like javascript:. This filter was susceptible to bypass through the use of C0 control characters, which are stripped by browsers during URL normalization.
The patch addresses this by introducing a new sanitization function, sanitizeMarkdownUrl. This function first strips any C0 control characters from the URL and then validates the URL's scheme against a strict allow-list (http, https, mailto, tel, ftp). The link and image renderer functions were updated to use this new, more secure sanitization logic. Any URL that does not have an allowed scheme is rejected, preventing the XSS vulnerability. An attacker exploiting this would need to inject malicious markdown into a session, which would then be triggered when a user exports that session to an HTML file and clicks the malicious link.