CVE-2026-49452 in WeasyPrintinfo

Summary

by MITRE • 08/18/2026

WeasyPrint helps web developers to create PDF documents. Prior to 69.0, WeasyPrint embeds unescaped HTML presentational-hint attribute values into CSS in weasyprint/css/__init__.py when presentational_hints=True. The background attribute is inserted into a background-image:url() declaration and parsed by tinycss2.parse_blocks_contents(), allowing untrusted HTML to inject additional CSS declarations. Applications that render untrusted HTML with presentational hints enabled can be affected by CSS injection and server-side requests through injected url() values. This issue is fixed in version 69.0.

If you want to get best quality of vulnerability data, you may have to visit VulDB.

Analysis

by VulDB Data Team • 08/18/2026

WeasyPrint serves as a widely utilized tool for web developers, enabling the conversion of HTML and CSS documents into high-quality PDF files. The vulnerability identified affects versions prior to 69.0 and centers on how the library handles presentational hints when processing untrusted input. Presentational hints are specific attributes in HTML that instruct rendering engines to apply certain visual styles directly from markup rather than relying solely on external or embedded style sheets. While this feature can simplify styling for simple documents, it introduces significant security risks if not handled with rigorous sanitization and escaping protocols.

The core technical flaw resides within the weasyprint/css/_init_.py module. When the presentational_hints configuration option is enabled, WeasyPrint attempts to translate HTML attributes into corresponding CSS declarations. Specifically, the background attribute from an HTML element is extracted and inserted directly into a background-image:url() declaration without proper escaping of special characters or validation of the content structure. This process relies on tinycss2.parse_blocks_contents() to parse the resulting CSS string. Because the input values are not adequately sanitized before being embedded into the CSS context, malicious actors can inject arbitrary CSS syntax that bypasses standard parsing expectations.

This lack of proper escaping allows for a classic CSS injection attack vector. An attacker who controls or influences the HTML content rendered by WeasyPrint can craft specific presentational hint attributes containing crafted payloads. By injecting additional CSS declarations through these unescaped values, an adversary can manipulate how the document is styled and processed. The most critical aspect of this vulnerability involves the url() function within CSS. When a malicious URL is injected into the background-image property, any application or service that subsequently processes the generated PDF may trigger network requests to the specified external resource.

The operational impact of this vulnerability extends beyond simple visual manipulation. It enables server-side request forgery scenarios where the rendering engine or downstream services make HTTP requests to attacker-controlled domains. This can lead to data exfiltration, as sensitive information might be transmitted via query parameters in the injected URLs. Furthermore, it facilitates port scanning and network reconnaissance if the target environment allows outbound connections from the service running WeasyPrint. In cloud-native environments or internal networks where such services operate with elevated privileges, this could potentially expose internal infrastructure details to external adversaries.

From a classification perspective, this vulnerability aligns with CWE-79, which covers Improper Neutralization of Input During Web Page Generation known as Cross-site Scripting (XSS), although in this context it manifests primarily through CSS injection rather than direct script execution. It also relates to CWE-20, Improper Input Validation, due to the failure to sanitize special characters within user-supplied attributes before embedding them into a code structure. In terms of offensive security frameworks, this behavior maps to ATT&CK technique T1568, Dynamic Resolution, where attackers use domain generation or similar techniques to establish command and control channels or exfiltrate data via DNS or HTTP requests triggered by the victim's system actions.

Mitigation strategies must prioritize immediate version upgrades for all systems utilizing WeasyPrint. Organizations should update their dependencies to version 69.0 or later, which includes patches that properly escape presentational hint values before they are processed into CSS declarations. For environments where upgrading is not immediately feasible, developers can implement a workaround by disabling the presentational_hints feature if it is not strictly required for document generation. Additionally, implementing strict input validation on any HTML content passed to WeasyPrint can reduce the risk of exploitation. Security teams should also monitor outbound network traffic from services using this library to detect potential indicators of compromise associated with unauthorized external requests triggered by malicious PDF rendering operations.

Responsible

GitHub M

Reservation

05/30/2026

Disclosure

08/18/2026

Moderation

accepted

CPE

ready

EPSS

0.00273

KEV

no

Activities

very low

Sources

Are you interested in using VulDB?

Download the whitepaper to learn more about our service!