Executive brief
WeasyPrint, a tool used to convert HTML and CSS into PDF documents, contains a vulnerability when processing certain HTML attributes. If an application uses WeasyPrint to process untrusted user content, an attacker could inject malicious styling instructions. This can be used to trigger unauthorized network requests from the server, potentially exposing internal metadata or other sensitive information.
Technical details
A CSS injection vulnerability exists in WeasyPrint's 'presentational hints' feature, specifically within 'weasyprint/css/__init__.py'. When 'presentational_hints=True' is configured, the library fails to properly escape HTML attribute values (such as the 'background' attribute) before embedding them into CSS 'url()' declarations. An attacker can provide a crafted HTML input to break out of the intended CSS property and inject arbitrary declarations. This can lead to Server-Side Request Forgery (SSRF) if the attacker injects 'url()' values pointing to internal network resources. As of the advisory date, no patched version is specified.
Affected products
- Kozea WeasyPrint <= 68.1
Timeline
- 2026-06-02: disclosed: Vulnerability reported to maintainer
- 2026-07-06: advisory: GitHub Advisory published