The vulnerability is an HTML injection in the PDF export functionality of the local-deep-research application, which can be chained to achieve Server-Side Request Forgery (SSRF). The core of the vulnerability lies in the PDFService._markdown_to_html function, where user-controlled input (title and metadata) is used to construct an HTML document without proper sanitization or escaping. This allows an attacker to inject arbitrary HTML tags.
The injected HTML is then processed by the WeasyPrint library within the PDFService.markdown_to_pdf function. In its vulnerable state, this function did not restrict WeasyPrint's ability to fetch external resources. Consequently, an attacker could inject an <img> or <link> tag with a src or href attribute pointing to an internal network address. When WeasyPrint renders the PDF, it makes a request to this internal address on behalf of the server, leading to SSRF. This could allow an attacker to access cloud provider metadata services, internal APIs, or other sensitive resources.
The remediation was applied in two stages. First, the HTML injection was fixed in _markdown_to_html by applying html.escape() to the user-provided data. Second, as a defense-in-depth measure, markdown_to_pdf was updated to use a custom url_fetcher that validates and blocks requests to internal or unsafe URLs, preventing the SSRF vector.