Skip to main content

CVE-2026-107378: CWE-407: Inefficient Algorithmic Complexity in Kozea CairoSVG

0
High
Published: 10/08/2026 (10/08/2026, 19:41:22 UTC)
Source: CVE Database V5
Vendor/Project: Kozea
Product: CairoSVG

Description

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

CVSS v4.0

Score 8.7high

Attack Vector
Network
Attack Complexity
Low
Attack Requirements
None
Privileges Required
None
User Interaction
None
Vuln. Confidentiality
None
Vuln. Integrity
None
Vuln. Availability
High
Subsq. Confidentiality
None
Subsq. Integrity
None
Subsq. Availability
None
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 software

Kozea

CairoSVG

Affected versions
<2.9.1
cairosvg
pkg:pypi/cairosvg
Affected versions
<2.9.1

Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.

AI-Powered Analysis

Machine-generated threat intelligence

AILast updated: 10/08/2026, 18:33:19 UTC

Technical Analysis

CVE-2026-107378 describes an inefficient algorithmic complexity vulnerability (CWE-407) in Kozea CairoSVG versions before 2.9.1. The vulnerability arises from the path tokenizer repeatedly slicing and rescanning path data and the draw_markers function draining node.vertices with repeated linear-time operations. When rendering an SVG with many path segments, this causes quadratic CPU consumption, potentially leading to denial of service. The svg2png, svg2pdf, and svg2ps APIs are affected as they invoke these rendering operations. The issue is resolved in version 2.9.1.

Potential Impact

An attacker can craft a sub-megabyte SVG file with many path segments that triggers excessive CPU consumption during rendering, causing denial of service to applications using CairoSVG for SVG conversion. This can degrade availability of services relying on CairoSVG rendering.

Mitigation Recommendations

Upgrade to CairoSVG version 2.9.1 or later, where this inefficiency and denial of service vulnerability has been fixed. No other mitigation is required as the fix addresses the root cause.

Pro Console: star threats, build custom feeds, automate alerts via Slack, email & webhooks.Upgrade to Pro

Technical Details

Data Version
5.2
Assigner Short Name
GitHub_M
Date Reserved
2026-10-07T21:07:54.987Z
Cvss Version
4.0
State
PUBLISHED

Threat ID: 6ac7df822cdf04f6562e1733

Added to database: 10/08/2026, 18:22:58 UTC

Last enriched: 10/08/2026, 18:33:19 UTC

Last updated: 10/08/2026, 21:45:50 UTC

Views: 9

Community Reviews

0 reviews

Crowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.

Sort by
Loading community insights…

Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.

Actions

PRO

Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.

Please log in to the Console to use AI analysis features.

Need more coverage?

Upgrade to Pro Console for AI refresh and higher limits.

For incident response and remediation, OffSeq services can help resolve threats faster.

Latest Threats

Breach by OffSeqOFFSEQFRIENDS — 25% OFF

Check if your credentials are on the dark web

Instant breach scanning across billions of leaked records. Free tier available.

Scan now
OffSeq TrainingCredly Certified

Lead Pen Test Professional

Technical5-day eLearningPECB Accredited
View courses