# CVE-2026-49452: WeasyPrint: CSS Injection via Presentational Hints

> Attackers can inject CSS via unescaped HTML attributes in WeasyPrint when presentational hints are enabled, potentially triggering server-side requests or code execution.

- **Severity:** Medium 6.5 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 18 Aug 2026
- **Updated:** 19 Aug 2026
- **Also known as:** DEBIAN-CVE-2026-49452, GHSA-jhhc-3hcp-qhm5, PYSEC-2026-3412, UBUNTU-CVE-2026-49452, openSUSE-SU-2026:11249-1, openSUSE-SU-2026:21364-1

## What is CVE-2026-49452?

CVE-2026-49452 is a medium-severity code injection vulnerability in Kozea WeasyPrint, published on 18 Aug 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official 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.

Weakness: CWE-74 (Improper Neutralization of Special Elements in Output Used by a Downstream Component)

## Which versions are affected by CVE-2026-49452?

3 open source packages ship an affected version, including weasyprint.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `weasyprint` | PyPI | All versions to 68.1 | None |
| `weasyprint` | PyPI | All versions to 68.1 | None |
| `weasyprint` | PyPI | All versions to 68.1 | None |
| `python-weasyprint` | openSUSE:Leap 16.0 | All versions | 65.1-bp160.3.1 |
| `python-weasyprint` | openSUSE:Tumbleweed | All versions | 69.0-1.1 |

## How do I fix CVE-2026-49452?

Upgrade to a fixed version.

## Is CVE-2026-49452 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2026-49452 exists.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2026-49452 and fix it if it is affected.

What it is: CVE-2026-49452 is a medium-severity code injection vulnerability in Kozea WeasyPrint, published on 18 Aug 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2026-49452 exists.

Affected packages and fixed versions:
- weasyprint (PyPI): affected all versions up to 68.1; no fix listed
- weasyprint (PyPI): affected all versions up to 68.1; no fix listed
- weasyprint (PyPI): affected all versions up to 68.1; no fix listed

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2026-49452/ (Markdown: https://insights.sbomify.com/CVE-2026-49452/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2026-49452
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2026-49452
- OSV: https://osv.dev/vulnerability/CVE-2026-49452

---
From sbomify Insights: https://insights.sbomify.com/CVE-2026-49452/
Summaries are generated and may contain mistakes; the official description above is the record.
