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.
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
<body background="x);background-image:url(http://169.254.169.254/latest/meta-data/)">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 VULN-05_css_injection_presentational_hints.md
Affected software
Click a technology to see all vulnerabilities affecting it.
| Platform | Package | Vulnerable versions | Fixed in |
|---|---|---|---|
| Python (PyPI) | weasyprint | <= 68.1 | no fix |
References
- CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N- Weakness (CWE)
CWE-74- Platform
- Python (PyPI)
- Package
weasyprint- Disclosed
- 06.07.2026
- Updated
- 11.10.2026 14:17
Sources and licenses
OSV / GitHub Advisory Database - PYSEC-2026-3412 - PyPA Advisory Database; CC BY 4.0
OSV / GitHub Advisory Database - GHSA-jhhc-3hcp-qhm5 - CC BY 4.0
Vulnerability history: weasyprint
All published vulnerabilities of this package (Python (PyPI)), newest first. Shows whether this is a one-off slip or a package that needs watching.
- Total entries
- 5
- First → latest
- 03.2024 10.2026
- Without a fix
- 1
- Exploited in attacks
- 0
Severity breakdown
- High 3
- Medium 2
Disclosures per year
- 2024: 1
- 2025: 0
- 2026: 4
-
WeasyPrint has CSS Injection via Presentational Hints this entry
Know which vulnerabilities affect your application
With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.