Home/Research/Post

GHSA-555j-qj3j-c8jv: svglib: Exponential resource consumption via nested references in svg2rlg

  • Severity: HIGH
  • CVE: CVE-2026-132275
  • Ecosystems: pip
  • Packages: svglib

# Summary

`svg2rlg()` expands “ references without any limit on the total number of expansions. Only direct cycles are rejected (`CircularRefError`). A group containing N “ 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 “ variant of the XML “billion laughs” attack (the same class as librsvg CVE-2019-20446).

# Details

`SvgRenderer.renderUse()` in `src/svglib/svglib.py`:

“`python
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 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 “ element and rendered. Any “ 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):

“`xml

… 10 times …
… 10 times …
…
… 10 times …

“`

# Impact

Denial of service (CPU and memory exhaustion…

Source: GitHub Security Advisories · 2026-11-20