PYSEC-2026-3412

Vulnerability from pysec - Published: 2026-07-13 15:46 - Updated: 2026-07-13 16:07
VLAI
Details

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

### 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)
Impacted products
Name purl
weasyprint pkg:pypi/weasyprint

{
  "affected": [
    {
      "package": {
        "ecosystem": "PyPI",
        "name": "weasyprint",
        "purl": "pkg:pypi/weasyprint"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "last_affected": "68.1"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ],
      "versions": [
        "0.1",
        "0.10",
        "0.11",
        "0.12",
        "0.13",
        "0.14",
        "0.15",
        "0.16",
        "0.17",
        "0.17.1",
        "0.18",
        "0.19",
        "0.19.1",
        "0.19.2",
        "0.2",
        "0.2.1",
        "0.2.2",
        "0.20",
        "0.20.1",
        "0.20.2",
        "0.21",
        "0.22",
        "0.23",
        "0.24",
        "0.25",
        "0.26",
        "0.27",
        "0.28",
        "0.29",
        "0.3",
        "0.3.1",
        "0.30",
        "0.31",
        "0.32",
        "0.33",
        "0.34",
        "0.35",
        "0.36",
        "0.37",
        "0.38",
        "0.39",
        "0.4",
        "0.40",
        "0.41",
        "0.42",
        "0.42.1",
        "0.42.2",
        "0.42.3",
        "0.5",
        "0.6",
        "0.6.1",
        "0.7",
        "0.7.1",
        "0.8",
        "0.9",
        "43",
        "43rc1",
        "43rc2",
        "44",
        "45",
        "46",
        "47",
        "48",
        "49",
        "50",
        "51",
        "52",
        "52.1",
        "52.2",
        "52.3",
        "52.4",
        "52.5",
        "53.0",
        "53.0b1",
        "53.0b2",
        "53.1",
        "53.2",
        "53.3",
        "53.4",
        "54.0",
        "54.0b1",
        "54.1",
        "54.2",
        "54.3",
        "55.0",
        "55.0b1",
        "56.0",
        "56.0b1",
        "56.1",
        "57.0",
        "57.0b1",
        "57.1",
        "57.2",
        "58.0",
        "58.0b1",
        "58.1",
        "59.0",
        "59.0b1",
        "60.0",
        "60.1",
        "60.2",
        "61.0",
        "61.1",
        "61.2",
        "62.0",
        "62.1",
        "62.2",
        "62.3",
        "63.0",
        "63.1",
        "64.0",
        "64.1",
        "65.0",
        "65.1",
        "66.0",
        "67.0",
        "68.0",
        "68.1"
      ]
    }
  ],
  "aliases": [
    "CVE-2026-49452",
    "GHSA-jhhc-3hcp-qhm5"
  ],
  "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\u003cbody background=\"x);background-image:url(http://169.254.169.254/latest/meta-data/)\"\u003e\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)",
  "id": "PYSEC-2026-3412",
  "modified": "2026-07-13T16:07:30.045914Z",
  "published": "2026-07-13T15:46:28.116294Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/Kozea/WeasyPrint/security/advisories/GHSA-jhhc-3hcp-qhm5"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/Kozea/WeasyPrint"
    },
    {
      "type": "PACKAGE",
      "url": "https://pypi.org/project/weasyprint"
    },
    {
      "type": "ADVISORY",
      "url": "https://github.com/advisories/GHSA-jhhc-3hcp-qhm5"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-49452"
    }
  ],
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N",
      "type": "CVSS_V3"
    }
  ],
  "summary": "WeasyPrint has CSS Injection via Presentational Hints"
}



Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Forecast uses a logistic model when the trend is rising, or an exponential decay model when the trend is falling. Fitted via linearized least squares.

Sightings

Author Source Type Date Other

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.

Loading…

Detection rules are retrieved from Rulezet.

Loading…

Loading…