CVE-2026-49452: Weasyprint WeasyPrint Has CSS Injection Vulnerability
MODERATECVE-2026-49452 is a MODERATE (CVSS 6.5) weasyprint has css injection vulnerability (CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')) affecting Weasyprint libraries in the PyPI ecosystem. The issue involves weasyprint has css injection via presentational hints. Remediation is available in the latest vendor maintenance releases.
CVE-2026-49452 at a Glance
Security Impact
CVSS: 6.5
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N).
How to Fix CVE-2026-49452
To remediate this vulnerability, upgrade all affected Weasyprint dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install weasyprint>=Latest secure release
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show weasyprint
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2026-49452, inspect your installed packages using pip:
pip show weasyprint
Analyze the terminal output to locate any version of Weasyprint in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than the patched release), your application is affected.
Note: The pip show weasyprint command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection'), where the product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. In Weasyprint, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-49452 Affected Weasyprint Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
weasyprint
|
PyPI |
≤ 68.1
|
|
References
Frequently Asked Questions
What is CVE-2026-49452?
Which Weasyprint versions are affected?
What version fixes CVE-2026-49452?
Is weasyprint affected?
What is the CVSS score of CVE-2026-49452?
What CWE is associated with CVE-2026-49452?
How can I check PyPI dependencies for CVE-2026-49452?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-jhhc-3hcp-qhm5",
"modified" : "2026-07-06T17:29:53Z",
"published" : "2026-07-06T17:29:53Z",
"aliases" : [ "CVE-2026-49452" ],
"summary" : "WeasyPrint has CSS Injection via Presentational Hints",
"details" : "### Summary\nA 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.\n\n### Details\nFile: weasyprint/css/__init__.py\n\nThe `background` attribute is used to construct CSS:\n\nbackground-image:url({element.get(\"background\")})\n\nThis string is parsed by `tinycss2.parse_blocks_contents()`.\n\nBecause the value is not escaped, additional CSS declarations can be injected.\n\n### PoC\n<body background=\"x);background-image:url(http://169.254.169.254/latest/meta-data/)\">\n\n### Impact\n- CSS injection\n- Server-side requests via injected `url()`\n- Limited to cases where `presentational_hints=True`\n\n### Suggested Fix\n- Escape attribute values before embedding into CSS\n- Restrict allowed values for presentational hints\n[VULN-05_css_injection_presentational_hints.md](https://github.com/user-attachments/files/26370718/VULN-05_css_injection_presentational_hints.md)",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "weasyprint"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"last_affected" : "68.1"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/Kozea/WeasyPrint/security/advisories/GHSA-jhhc-3hcp-qhm5"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/Kozea/WeasyPrint"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-74" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2026-07-06T17:29:53Z",
"nvd_published_at" : null
}
}