CVE-2026-31899: Kozea CairoSVG exponential denial of service in defs.py

CVE-2026-31899 · Severity: high · CVSS 7.5 · Published 2026-03-13

CairoSVG is a popular library used to convert SVG files into other formats like PNG or PDF. A vulnerability allows an attacker to provide a specially crafted, small SVG file that causes the system to consume 100% of its CPU resources indefinitely. This can lead to a complete service outage for any application that processes user-provided images, such as profile picture uploaders or document generators.

Technologies: CairoSVG (PyPI). Vendors: PyPI.

Quick answers

Is CVE-2026-31899 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2026-31899 being exploited in the wild.
How severe is CVE-2026-31899?
High severity, with a CVSS score of 7.5, published 13 March 2026.
Which products and versions are affected?
CairoSVG (PyPI) <= 2.8.2, ECOSYSTEM:introduced=0,fixed=2.9.0.
Is there a fix for CVE-2026-31899?
Yes. CairoSVG (PyPI): upgrade to 2.9.0 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2026-31899 attacked?
It is attacked over the network, in a software library.
Am I affected by CVE-2026-31899?
Check whether you run CairoSVG (PyPI) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • CairoSVG (PyPI): upgrade to 2.9.0 or later
    pip install "CairoSVG>=2.9.0"

Technical details

The vulnerability exists in the `use()` function within `cairosvg/defs.py`. The component fails to implement recursion depth limits or element budget constraints when processing SVG `<use>` elements. An attacker can craft a nested SVG structure where each level references the previous one multiple times, leading to O(10^N) rendering calls from a small input (e.g., a 1.4KB file). This results in indefinite CPU exhaustion without triggering Out-of-Memory (OOM) killers, as memory usage remains relatively flat. The issue is fixed in version 2.9.0.

Affected products

  • Kozea CairoSVG <= 2.8.2

Identifiers

  • CVE-2026-31899
  • GHSA-f38f-5xpm-9r7c
  • PYSEC-2026-2122

Timeline

  • 2026-03-13: disclosed
  • 2026-03-13: advisory
  • 2026-03-13: patched: Fixed in version 2.9.0

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.