CVE-2026-49452: Weasyprint WeasyPrint Has CSS Injection Vulnerability

MODERATE
Advisory Identifier: GHSA-jhhc-3hcp-qhm5
CVSS 6.5
CWE-74
Published
Advisory Summary

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

CVE Identifier CVE-2026-49452
GHSA Identifier GHSA-jhhc-3hcp-qhm5
Severity MODERATE
CVSS v3.1 Base Score 6.5
CWE Classification CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
Affected Product Weasyprint
Package Ecosystem PyPI
Published Date
Last Updated

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

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability None (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.

weasyprint fixed: Latest secure release
pip install weasyprint>=Latest secure release
Verify Direct and Transitive Dependencies

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

### 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](https://github.com/user-attachments/files/26370718/VULN-05_css_injection_presentational_hints.md)

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?
CVE-2026-49452 is a security vulnerability in Weasyprint involving WeasyPrint has CSS Injection via Presentational Hints under CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection').
Which Weasyprint versions are affected?
Affected versions include releases prior to current release patches across affected packages: weasyprint.
What version fixes CVE-2026-49452?
Upgrading to current release patches (or the latest patched release for your respective branch) resolves the vulnerability.
Is weasyprint affected?
Yes, weasyprint is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What is the CVSS score of CVE-2026-49452?
CVE-2026-49452 has a CVSS v3.1 base score of 6.5 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N.
What CWE is associated with CVE-2026-49452?
CVE-2026-49452 is classified under CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') (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.).
How can I check PyPI dependencies for CVE-2026-49452?
Run the dependency tree command: 'pip show weasyprint'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "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
  }
}