Vulnerabilities in pkg:pypi/cairosvg

PACKAGE
Advisory Identifier: GHSA-c3jg-qh8m-j3h2
Advisory Summary

CVE-2026-107378 is a HIGH denial of service vulnerability (CWE-407: Inefficient Algorithmic Complexity) affecting CairoSVG libraries in the PyPI ecosystem. The issue involves quadratic-time dos parsing a crafted svg <path>. Remediation is available by upgrading affected packages to version 2.9.1.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:pypi/cairosvg

1 Known Advisory Record(s)

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

Advisory ID CVE / NVD Severity Summary
GHSA-c3jg-qh8m-j3h2 CVE-2026-107378 HIGH CairoSVG: Quadratic-time DoS parsing a crafted SVG <path>

CVE-2026-107378 at a Glance

CVE Identifier CVE-2026-107378
GHSA Identifier GHSA-c3jg-qh8m-j3h2
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification CWE-407: Inefficient Algorithmic Complexity
Affected Product CairoSVG
Package Ecosystem PyPI
Published Date
Last Updated

How to Fix CVE-2026-107378

To remediate this vulnerability, upgrade all affected CairoSVG dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

cairosvg fixed: 2.9.1
pip install cairosvg>=2.9.1
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 cairosvg

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-107378, inspect your installed packages using pip:

pip show cairosvg

Analyze the terminal output to locate any version of CairoSVG in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.9.1), your application is affected.

Note: The pip show cairosvg command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-407: Inefficient Algorithmic Complexity, where an algorithm in a product has an inefficient worst-case computational complexity that may be detrimental to system performance and can be triggered by an attacker, typically using crafted manipulations that ensure that the worst case is being reached. In CairoSVG, 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 Rendering an untrusted SVG whose `<path d="...">` contains many segments is O(n²) CPU. A single `<path>` under 1 MiB burns tens of seconds. Two independent O(n²) sites in `cairosvg/path.py`: 1. **Tokenizer** — the path-data parser consumes the `d` string with a `while string:` loop that repeatedly slices/re-scans the *remaining* string (each step is O(len remaining)), giving O(n²) over the whole attribute. 2. **draw_markers** — marker handling drains `node.vertices` with `while node.vertices: ... node.vertices.pop(0)`; `list.pop(0)` is O(n), so draining n vertices is O(n²). Both are hit on a normal render path (`svg2png`/`svg2pdf`), attacker controls only the SVG document. ## PoC (installed cairosvg 2.9.0) ```python import cairosvg d = "M0 0 " + "L1 1 " * 100000 svg = f'<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10"><path d="{d}"/></svg>' cairosvg.svg2png(bytestring=svg.encode()) # ~4.4 s for a 488 KB doc ``` | path segments | SVG size | time | |---|---|---| | 50,000 | 244 KB | 1.14 s | | 100,000 | 488 KB | 4.36 s | | 200,000 | ~960 KB | ~18 s | Doubling segments ≈ 4× time ⇒ quadratic. Sub-MiB input ⇒ ~18 s CPU; any service rendering user-supplied SVG (thumbnails, avatars, PDF export) is a DoS target. ## Reachability Public API `svg2png` / `svg2pdf` / `svg2ps` on an untrusted SVG string. ## Suggested fix Tokenize with a single forward scan / index (or `re.finditer`) instead of re-slicing the remainder; drain `vertices` with an index or `collections.deque.popleft` instead of `list.pop(0)`. Optionally cap path-segment count.

CVE-2026-107378 Affected CairoSVG Versions

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

References

Frequently Asked Questions

What is CVE-2026-107378?
CVE-2026-107378 is a security vulnerability in CairoSVG involving Quadratic-time DoS parsing a crafted SVG <path> under CWE-407: Inefficient Algorithmic Complexity.
Which CairoSVG versions are affected?
Affected versions include releases prior to 2.9.1 across affected packages: cairosvg.
What version fixes CVE-2026-107378?
Upgrading to 2.9.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is cairosvg affected?
Yes, cairosvg is affected in releases prior to 2.9.1. Upgrade your dependency to 2.9.1 or later.
What CWE is associated with CVE-2026-107378?
CVE-2026-107378 is classified under CWE-407: Inefficient Algorithmic Complexity (An algorithm in a product has an inefficient worst-case computational complexity that may be detrimental to system performance and can be triggered by an attacker, typically using crafted manipulations that ensure that the worst case is being reached.).
How can I check PyPI dependencies for CVE-2026-107378?
Run the dependency tree command: 'pip show cairosvg'. 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-c3jg-qh8m-j3h2",
  "modified" : "2026-10-08T19:41:22Z",
  "published" : "2026-10-08T19:41:22Z",
  "aliases" : [ "CVE-2026-107378" ],
  "summary" : "CairoSVG: Quadratic-time DoS parsing a crafted SVG <path>",
  "details" : "## Summary\n\nRendering an untrusted SVG whose `<path d=\"...\">` contains many segments is O(n²) CPU. A single `<path>` under 1 MiB burns tens of seconds. Two independent O(n²) sites in `cairosvg/path.py`:\n\n1. **Tokenizer** — the path-data parser consumes the `d` string with a `while string:` loop that repeatedly slices/re-scans the *remaining* string (each step is O(len remaining)), giving O(n²) over the whole attribute.\n2. **draw_markers** — marker handling drains `node.vertices` with `while node.vertices: ... node.vertices.pop(0)`; `list.pop(0)` is O(n), so draining n vertices is O(n²).\n\nBoth are hit on a normal render path (`svg2png`/`svg2pdf`), attacker controls only the SVG document.\n\n## PoC (installed cairosvg 2.9.0)\n\n```python\nimport cairosvg\nd = \"M0 0 \" + \"L1 1 \" * 100000\nsvg = f'<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"10\" height=\"10\"><path d=\"{d}\"/></svg>'\ncairosvg.svg2png(bytestring=svg.encode())   # ~4.4 s for a 488 KB doc\n```\n\n| path segments | SVG size | time |\n|---|---|---|\n| 50,000 | 244 KB | 1.14 s |\n| 100,000 | 488 KB | 4.36 s |\n| 200,000 | ~960 KB | ~18 s |\n\nDoubling segments ≈ 4× time ⇒ quadratic. Sub-MiB input ⇒ ~18 s CPU; any service rendering user-supplied SVG (thumbnails, avatars, PDF export) is a DoS target.\n\n## Reachability\n\nPublic API `svg2png` / `svg2pdf` / `svg2ps` on an untrusted SVG string.\n\n## Suggested fix\n\nTokenize with a single forward scan / index (or `re.finditer`) instead of re-slicing the remainder; drain `vertices` with an index or `collections.deque.popleft` instead of `list.pop(0)`. Optionally cap path-segment count.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "cairosvg"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.9.1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 2.9.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/Kozea/CairoSVG/security/advisories/GHSA-c3jg-qh8m-j3h2"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-107378"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Kozea/CairoSVG/commit/9d63f049f9988d0ddda3eb94564ac3a50a286523"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Kozea/CairoSVG/commit/a4d585eb374724b79676e9cceaa9e9a1a4358565"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/Kozea/CairoSVG"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Kozea/CairoSVG/releases/tag/2.9.1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-407" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-10-08T19:41:22Z",
    "nvd_published_at" : "2026-10-08T18:17:23Z"
  }
}