Skip to main content
Vulnerability Database/CVE-2026-107378

CVE-2026-107378: CairoSVG Path Rendering DoS Vulnerability

CVE-2026-107378 is a denial of service flaw in CairoSVG that causes quadratic CPU consumption when rendering SVGs with complex paths. Attackers can exploit this to deny service with minimal input. This post covers technical details, affected versions, impact assessment, and mitigation strategies.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2026-107378 Overview

CairoSVG is a Python-based SVG converter built on the Cairo 2D graphics library. CVE-2026-107378 is an algorithmic complexity vulnerability [CWE-407] affecting CairoSVG versions prior to 2.9.1. Rendering an attacker-controlled SVG that contains a path with many segments triggers quadratic CPU consumption inside cairosvg/path.py. The path tokenizer repeatedly slices and rescans remaining path data, while draw_markers drains node.vertices using node.vertices.pop(0), producing repeated linear-time work. The svg2png, svg2pdf, and svg2ps APIs all reach these operations during normal rendering. A sub-megabyte SVG is sufficient to exhaust CPU resources and deny service to the rendering application.

Critical Impact

A sub-megabyte malicious SVG processed through CairoSVG's standard rendering APIs can exhaust CPU resources and cause denial of service in any application that renders untrusted SVG input.

Affected Products

  • CairoSVG versions prior to 2.9.1
  • Python applications using svg2png, svg2pdf, or svg2ps APIs
  • Web services and document pipelines accepting untrusted SVG uploads

Discovery Timeline

  • 2026-10-08 - CVE-2026-107378 published to NVD
  • 2026-10-08 - Last updated in NVD database

Technical Details for CVE-2026-107378

Vulnerability Analysis

The flaw is an algorithmic complexity issue in CairoSVG's SVG path processing pipeline. When CairoSVG parses an SVG <path> element, the tokenizer in cairosvg/path.py operates on the raw path string by repeatedly slicing it to remove consumed tokens. Each slice operation copies the remaining buffer, so processing a path with N segments requires O(N²) time.

A second hotspot exists in marker rendering. The draw_markers function iterates by calling node.vertices.pop(0) on a Python list, which forces a shift of every remaining element on each call. Draining a vertex list of length N using pop(0) is also O(N²).

Because both the tokenizer and the marker drainer are reached from svg2png, svg2pdf, and svg2ps, any workflow that renders untrusted SVG content is exposed. The attacker needs no authentication and no user interaction beyond submitting an SVG for rendering.

Root Cause

The root cause is the use of inefficient data-structure operations on attacker-controlled, variable-length input. String slicing in the path tokenizer and list.pop(0) on vertex sequences both exhibit linear-time behavior per element, producing quadratic total runtime when the input scales. CairoSVG applied no upper bound on path segment counts, allowing a compact SVG to translate into disproportionate CPU work.

Attack Vector

An attacker crafts an SVG document containing a path with a large number of segments and submits it to any application or service that converts SVG to PNG, PDF, or PostScript using CairoSVG. The request completes quickly from the attacker's perspective, but the server consumes substantial CPU time per request. Repeated submissions can monopolize worker processes and deny service to legitimate users.

python
# Patch 1: Replace slice-based tokenizer with regex iterator in cairosvg/path.py
# Source: https://github.com/Kozea/CairoSVG/commit/9d63f049f9988d0ddda3eb94564ac3a50a286523
from collections import deque
from math import copysign, hypot, pi, radians
from re import finditer

from .bounding_box import calculate_bounding_box
from .helpers import (
    # ...
)

# Patch 2: Replace list.pop(0) with deque.popleft() in cairosvg/path.py and cairosvg/shapes.py
# Source: https://github.com/Kozea/CairoSVG/commit/a4d585eb374724b79676e9cceaa9e9a1a4358565
from collections import deque
from math import copysign, hypot, pi, radians

Detection Methods for CVE-2026-107378

Indicators of Compromise

  • Sustained high CPU usage in Python processes that invoke cairosvg.svg2png, svg2pdf, or svg2ps.
  • Request handlers or worker processes blocked for seconds or minutes on single SVG inputs under one megabyte.
  • Timeouts, 502 or 504 responses from services that accept uploaded SVG files.

Detection Strategies

  • Inventory applications that import cairosvg and verify installed versions are at or above 2.9.1.
  • Instrument SVG rendering endpoints with per-request CPU and wall-clock metrics to flag outliers.
  • Pre-scan incoming SVG files for <path> elements with extreme segment counts prior to rendering.

Monitoring Recommendations

  • Alert on repeated SVG rendering requests from a single source that exceed baseline CPU time.
  • Track process-level CPU saturation on hosts running CairoSVG workloads.
  • Review web application firewall and reverse proxy logs for bursts of SVG uploads followed by timeouts.

How to Mitigate CVE-2026-107378

Immediate Actions Required

  • Upgrade CairoSVG to version 2.9.1 or later across all environments, including container images and build pipelines.
  • Enforce CPU and wall-clock timeouts on any process that renders user-supplied SVG content.
  • Restrict upload size and reject SVGs with abnormally large <path> segment counts until patched.

Patch Information

The fix is available in CairoSVG 2.9.1. The upstream patches replace slice-based tokenization with a regex iterator in cairosvg/path.py and switch vertex storage from list with pop(0) to collections.deque with popleft(). See the CairoSVG Security Advisory GHSA-c3jg-qh8m-j3h2 and the CairoSVG 2.9.1 release notes.

Workarounds

  • Run CairoSVG rendering in isolated worker processes with hard CPU and memory limits using cgroups, ulimit, or container resource constraints.
  • Reject SVG inputs whose <path>d attribute exceeds a conservative length or segment-count threshold.
  • Queue SVG rendering jobs with per-tenant rate limits to prevent a single caller from exhausting shared workers.
bash
# Upgrade to the patched version
pip install --upgrade 'cairosvg>=2.9.1'

# Verify the installed version
python -c "import cairosvg; print(cairosvg.__version__)"

# Example: enforce a CPU time limit on a rendering worker (Linux)
ulimit -t 5

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.