# CVE-2026-31899: CairoSVG vulnerable to Exponential DoS via recursive <use> element amplification

> An attacker can cause CPU exhaustion and denial of service by submitting a crafted SVG file with recursive use elements to applications using CairoSVG.

- **Severity:** High 7.5 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 13 Mar 2026
- **Updated:** 16 Mar 2026
- **Also known as:** DEBIAN-CVE-2026-31899, GHSA-f38f-5xpm-9r7c, MGASA-2026-0104, PYSEC-2026-2122, ROOT-APP-PYPI-CVE-2026-31899, SUSE-SU-2026:1421-1, SUSE-SU-2026:22024-1, UBUNTU-CVE-2026-31899, openSUSE-SU-2026:10379-1, openSUSE-SU-2026:11729-1, openSUSE-SU-2026:20886-1

## What is CVE-2026-31899?

CVE-2026-31899 is a high-severity denial of service vulnerability in Kozea CairoSVG, published on 13 Mar 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

CairoSVG is an SVG converter based on Cairo, a 2D graphics library. Prior to Kozea/CairoSVG has exponential denial of service via recursive <use> element amplification in cairosvg/defs.py. This causes CPU exhaustion from a small input.

Weakness: CWE-674 (Uncontrolled Recursion)

## Which versions are affected by CVE-2026-31899?

3 open source packages ship an affected version, including cairosvg and CairoSVG. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `cairosvg` | PyPI | All versions | 2.9.0 |
| `cairosvg` | PyPI | All versions | 2.9.0 |
| `CairoSVG` | PyPI | All versions | 2.9.0 |
| `python-CairoSVG` | SUSE:Linux Enterprise Module for Python 3 15 SP7 | All versions | 2.7.1-150400.9.6.1 |
| `python-CairoSVG` | SUSE:Linux Enterprise Server 16.0 | All versions | 2.7.1-160000.3.1 |
| `python-CairoSVG` | SUSE:Linux Enterprise Server for SAP applications 16.0 | All versions | 2.7.1-160000.3.1 |
| `python-CairoSVG` | openSUSE:Leap 15.6 | All versions | 2.7.1-150400.9.6.1 |
| `ansible-creator` | openSUSE:Tumbleweed | All versions | 26.8.0-1.1 |
| `python-CairoSVG` | openSUSE:Tumbleweed | All versions | 2.9.0-1.1 |

Products: Courtbouillon Cairosvg.

## How do I fix CVE-2026-31899?

Upgrade cairosvg to 2.9.0 or later.

## Is CVE-2026-31899 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2026-31899 exists.

Public exploit code:

- CVE-2026-31899: Exponential DoS via Recursive <use> Element Amplification in CairoSVG (CVSS 7.5 High) (github_poc): https://github.com/SnailSploit/CVE-2026-31899

## Other vulnerabilities in Kozea CairoSVG

- [CVE-2023-27586](https://insights.sbomify.com/CVE-2023-27586/): CairoSVG improperly processes SVG files loaded from external resources (critical 9.9)
- [CVE-2021-21236](https://insights.sbomify.com/CVE-2021-21236/): Regular Expression Denial of Service in CairoSVG (medium 5.7)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2026-31899 and fix it if it is affected.

What it is: CVE-2026-31899 is a high-severity denial of service vulnerability in Kozea CairoSVG, published on 13 Mar 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2026-31899 exists.

Affected packages and fixed versions:
- cairosvg (PyPI): affected all versions; fixed in 2.9.0
- cairosvg (PyPI): affected all versions; fixed in 2.9.0
- CairoSVG (PyPI): affected all versions; fixed in 2.9.0

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2026-31899/ (Markdown: https://insights.sbomify.com/CVE-2026-31899/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2026-31899
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2026-31899
- OSV: https://osv.dev/vulnerability/CVE-2026-31899

---
From sbomify Insights: https://insights.sbomify.com/CVE-2026-31899/
Summaries are generated and may contain mistakes; the official description above is the record.
