CVE-2026-49452: WeasyPrint has CSS Injection via Presentational Hints
Summary A CSS injection issue exists in WeasyPrint when HTML presentational hints are enabled. Unescaped attribute values are embedded into CSS, allowing injection of arbitrary CSS declarations. This affects applications processing untrusted HTML input.
Published Jul 6, 2026
Affected packages
weasyprint
- Ecosystem
- PyPI
- Affected
- <= 68.1
- Fixed in
- No patched version yet
- Check
pip show weasyprint
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
Summary
A CSS injection issue exists in WeasyPrint when HTML presentational hints are enabled. Unescaped attribute values are embedded into CSS, allowing injection of arbitrary CSS declarations. This affects applications processing untrusted HTML input.
Details
File: weasyprint/css/__init__.py
The background attribute is used to construct CSS:
background-image:url({element.get("background")})
This string is parsed by tinycss2.parse_blocks_contents().
Because the value is not escaped, additional CSS declarations can be injected.
PoC
Impact
- CSS injection
- Server-side requests via injected
url() - Limited to cases where
presentational_hints=True
Suggested Fix
- Escape attribute values before embedding into CSS
- Restrict allowed values for presentational hints
Credited to AyushParkara.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More PyPI vulnerabilities
All PyPI entriesCVE-2026-55073
weasyprint Has Server-Side Request Forgery (SSRF)
medium6.2Sep 9, 2026CVE-2025-68616
WeasyPrint has a Server-Side Request Forgery (SSRF) Protection Bypass via HTTP Redirect
high7.5Jan 20, 2026CVE-2024-28184
WeasyPrint allows the attachment of arbitrary files and URLs to a PDF
high7.4Mar 8, 2024
