CVE-2026-49452
JSON

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 packageVersionsReported by
Kozea WeasyPrint< 69.0CVE List
weasyprint (PyPI)up to 68.1GitHub Advisory Database, PyPA Advisory Database

All scores

GitHub_M6.5medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N
GitHub6.5medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N
PyPA Advisory Database6.5medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N

Classification

CWE-74

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
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

SourceRecordLicence
CVE ListCVE-2026-49452 changed 2026-08-19CVE Terms of Use
GitHub Advisory DatabaseGHSA-jhhc-3hcp-qhm5 changed 2026-07-13CC-BY-4.0
NVDCVE-2026-49452 changed 2026-10-22Public domain
PyPA Advisory DatabasePYSEC-2026-3412 changed 2026-07-13CC-BY-4.0