6.5medium
WeasyPrint: CSS Injection via Presentational Hints
- Severity
- 6.5medium CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.34% (higher than 28% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-jhhc-3hcp-qhm5PYSEC-2026-3412
Description
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.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| Kozea WeasyPrint | < 69.0 | CVE List |
| weasyprint (PyPI) | up to 68.1 | GitHub Advisory Database, PyPA Advisory Database |
All scores
| GitHub_M | 6.5medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N |
| GitHub | 6.5medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N |
| PyPA Advisory Database | 6.5medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N |
Classification
SSVC (CISA-ADP): exploitation poc, automatable yes, technical impact partial.
What each source says
CVE List
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.
GitHub Advisory Database
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
NVD (es)
WeasyPrint ayuda a los desarrolladores web a crear documentos PDF. Antes de la versión 69.0, WeasyPrint incrusta valores de atributos de sugerencia presentacional HTML sin escapar en CSS en weasyprint/css/__init__.py cuando presentational_hints=True. El atributo background se inserta en una declaración background-image:url() y es analizado por tinycss2.parse_blocks_contents(), permitiendo que HTML no confiable inyecte declaraciones CSS adicionales. Las aplicaciones que renderizan HTML no confiable con las sugerencias presentacionales habilitadas pueden verse afectadas por inyección CSS y solicitudes del lado del servidor a través de valores url() inyectados. Este problema se ha solucionado en la versión 69.0.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-49452 changed 2026-08-19 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-jhhc-3hcp-qhm5 changed 2026-07-13 | CC-BY-4.0 |
| NVD | CVE-2026-49452 changed 2026-10-22 | Public domain |
| PyPA Advisory Database | PYSEC-2026-3412 changed 2026-07-13 | CC-BY-4.0 |