{"id":"CVE-2026-107378","aliases":["CVE-2026-107378","GHSA-c3jg-qh8m-j3h2","PYSEC-2026-4204"],"related":[],"kind":"vulnerability","state":"published","title":"CairoSVG: Quadratic-time DoS parsing a crafted SVG <path>","summary":"CairoSVG is an SVG converter based on Cairo, a 2D graphics library. Prior to 2.9.1, rendering an attacker-controlled SVG with a path containing many segments can cause quadratic CPU consumption in cairosvg/path.py. The path tokenizer repeatedly slices and rescans the remaining path data, while draw_markers drains node.vertices with node.vertices.pop(0), causing repeated linear-time work. The svg2png, svg2pdf, and svg2ps APIs reach these operations during ordinary rendering, allowing a sub-megabyte SVG to consume substantial CPU and deny service to a rendering application. This issue is fixed in version 2.9.1.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"CairoSVG is an SVG converter based on Cairo, a 2D graphics library. Prior to 2.9.1, rendering an attacker-controlled SVG with a path containing many segments can cause quadratic CPU consumption in cairosvg/path.py. The path tokenizer repeatedly slices and rescans the remaining path data, while draw_markers drains node.vertices with node.vertices.pop(0), causing repeated linear-time work. The svg2png, svg2pdf, and svg2ps APIs reach these operations during ordinary rendering, allowing a sub-megabyte SVG to consume substantial CPU and deny service to a rendering application. This issue is fixed in version 2.9.1.","source":"cvelist"},{"lang":"en","text":"## 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.","format":"markdown","source":"ghsa"}],"published":"2026-10-08T17:59:09.505Z","modified":"2026-10-15T14:56:21.119Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"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","score":8.7,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"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","score":8.7,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"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","rating":"HIGH"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:4.0","vector":"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"}],"cwes":["CWE-407"],"affected":[{"ranges":[{"version":"< 2.9.1","status":"affected"}],"vendor":"Kozea","product":"CairoSVG","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"2.9.1"}],"ecosystem":"PyPI","package":"cairosvg","purl":"pkg:pypi/cairosvg","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"2.9.1"}],"ecosystem":"PyPI","package":"cairosvg","purl":"pkg:pypi/cairosvg","source":"pysec"}],"references":[{"url":"https://github.com/Kozea/CairoSVG/security/advisories/GHSA-c3jg-qh8m-j3h2","tags":["exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/Kozea/CairoSVG/commit/9d63f049f9988d0ddda3eb94564ac3a50a286523","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/Kozea/CairoSVG/commit/a4d585eb374724b79676e9cceaa9e9a1a4358565","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/Kozea/CairoSVG/releases/tag/2.9.1","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-107378","tags":["advisory"],"sources":["ghsa","pysec"]},{"url":"https://github.com/Kozea/CairoSVG","tags":["package"],"sources":["ghsa","pysec"]},{"url":"https://pypi.org/project/cairosvg","tags":["package"],"sources":["pysec"]},{"url":"https://github.com/advisories/GHSA-c3jg-qh8m-j3h2","tags":["advisory"],"sources":["pysec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2026-10-08T18:31:09.975Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-107378","url":"https://www.cve.org/CVERecord?id=CVE-2026-107378","licence":"CVE Terms of Use","modified":"2026-10-08T18:31:17.147Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-c3jg-qh8m-j3h2","url":"https://github.com/advisories/GHSA-c3jg-qh8m-j3h2","licence":"CC-BY-4.0","modified":"2026-10-15T14:56:21.119Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-107378","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-107378","licence":"Public domain","modified":"2026-10-08T21:33:42.423Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-4204","url":"https://osv.dev/vulnerability/PYSEC-2026-4204","licence":"CC-BY-4.0","modified":"2026-10-15T14:45:05.910Z"}],"updatedAt":"2026-11-25T22:59:43.199Z","epss":{"score":0.00383,"percentile":0.34463,"date":"2026-12-01T12:00:22.000Z"}}