CairoSVG 2.9.1 Fixes High-Severity Denial-of-Service Vulnerability in SVG Rendering
A quadratic CPU consumption flaw in older CairoSVG versions allows attackers to crash services with small files. Version 2.9.1 resolves the issue.

Key points
- CVE-2026-107378 is rated high severity with a CVSS score of 8.7.
- The flaw causes denial of service via inefficient path tokenization and marker drawing.
- Version 2.9.1 patches the vulnerability; users of versions 2.9.0 and earlier are affected.
Kozea has released version 2.9.1 of CairoSVG to address a high-severity denial-of-service vulnerability that allows attackers to consume excessive CPU resources through specially crafted SVG files. The flaw, tracked as CVE-2026-107378, affects all versions of the library prior to 2.9.1.
At a glance
- CVE
- CVE-2026-107378
- Product
- Kozea CairoSVG
- CVSS
- 8.7 High
- Weakness
- CWE-407
- Exploited
- No known exploitation
The vulnerability stems from inefficient code within the `cairosvg/path.py` module, which processes SVG path data. According to the GitHub advisory GHSA-c3jg-qh8m-j3h2, two independent operations in the library exhibit quadratic time complexity, or O(n²), when handling paths with many segments. The first issue occurs in the path tokenizer, which repeatedly slices and rescans the remaining string data in a loop. The second issue arises in the `draw_markers` function, which removes items from the start of a list using `list.pop(0)`, an operation that becomes increasingly slow as the list lengthens.
Technical Context
An attacker can exploit this weakness by supplying an SVG document containing a single `<path>` element with a large number of segments. The source material indicates that an SVG file smaller than one megabyte can cause substantial CPU consumption, effectively denying service to the application rendering the file. Testing described in the advisory shows that doubling the number of path segments approximately quadruples the processing time. For example, a 488 KB file with 100,000 segments took 4.36 seconds to process, while a nearly 1 MB file with 200,000 segments took approximately 18 seconds.
The vulnerability is reachable through standard public APIs, including `svg2png`, `svg2pdf`, and `svg2ps`. Because these functions are commonly used for generating thumbnails, avatars, or PDF exports from user-supplied content, any service that renders untrusted SVGs is a potential target for denial-of-service attacks. The National Vulnerability Database lists the weakness under CWE-407.
Affected Systems
The vulnerability impacts the `cairosvg` package available via pip. Versions 2.9.0 and earlier are vulnerable. The fix is included in version 2.9.1. The advisory notes that the suggested fix involves changing the tokenization logic to use a single forward scan or index instead of re-slicing the remainder of the string. Additionally, the marker handling code should be updated to use an index or `collections.deque.popleft` instead of `list.pop(0)` to avoid linear-time removal operations. Optionally, developers may cap the path-segment count to further mitigate resource exhaustion.
What should you do?
Users of CairoSVG should update to version 2.9.1 immediately if they have not already done so. Organizations that render user-supplied SVG files should verify their current library version. If updating is not immediately possible, consider restricting the size or complexity of accepted SVG files to limit the impact of potential attacks. Monitor vendor channels for any further updates or advisories related to this component.
Background: Tokenization
Tokenization and chunking serve different domains. Tokenization is a security control that substitutes sensitive data with non-sensitive equivalents. Chunking is a data processing technique that divides large inputs into smaller segments. You use tokenization to protect privacy. You use chunking to manage computational limits.
Read the full guide: Difference Between Tokenization and Chunking: Security vs NLP
What to do and how to stay safe: CairoSVG
- Check your project dependencies to determine if you are using CairoSVG version 2.9.0 or older.
- Update the library to version 2.9.1 or later to apply the official fix.
- If you cannot update immediately, implement input validation to restrict the size and complexity of SVG files accepted by your application.
- Monitor system resource usage for applications that render user-supplied SVGs to detect potential denial-of-service attempts.
Step-by-step guide: Risk Based Vulnerability Management: Prioritize Fixes by Actual Threat
General security guidance from the Threat Times newsroom. It is not confirmed advice from the organisations named in this story.
Frequently asked questions
What is the CVSS score for CVE-2026-107378?
The CVSS score is 8.7, which is rated as high severity.
Which versions of CairoSVG are affected by this vulnerability?
All versions prior to 2.9.1 are affected, including version 2.9.0.
Is there a fix available for this vulnerability?
Yes, the vulnerability is fixed in version 2.9.1 of CairoSVG.


