# CVE-2026-132275 — svglib: nested `` references expand without limit (SVG billion-laughs DoS) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) [![Research status: validated](https://img.shields.io/badge/research-validated%20differential-success.svg)](#5-expected-results) | | | | --- | --- | | **CVE** | CVE-2026-132275 | | **Component** | svglib — `svg2rlg()` / `SvgRenderer` `` expansion (`src/svglib/svglib.py`) | | **Affected** | <= 2.3.0 | | **Fixed in** | **2.3.1** — commits `c4cddf3`, `f7ce0f0` (GHSA-555j-qj3j-c8jv) | | **CWE** | CWE-776 (Improper Restriction of Recursive Entity References), CWE-400 (Uncontrolled Resource Consumption) | | **Impact** | A ~1.4KB attacker-supplied SVG with nested `` groups drives 100,000+ node clones — tens of seconds of CPU and hundreds of MiB of memory; each extra level adds ~245 bytes and multiplies work by ~10 (the SVG `` variant of XML billion-laughs) | | **Vector** | Any service converting untrusted SVG with `svg2rlg()` | | **Trigger** | nested `` each holding 10 `` | The vulnerable renderer expanded `` references with no total bound: ```python # svglib 2.3.0 — only direct cycles were rejected (CircularRefError); # a group of N elements pointing at another such group multiplies # work by N per nesting level, without limit. ``` The fix caps total expansions: ```python # svglib 2.3.1 MAX_USE_EXPANSIONS = 10_000 self._use_expansions.count += 1 if self._use_expansions.count > MAX_USE_EXPANSIONS: logger.error("Too many expansions (limit is %d), skipping the rest", MAX_USE_EXPANSIONS) return group ``` --- ## 1. Root cause `svg2rlg()` expands `` references by cloning the referenced group into the render tree. Only *direct* cycles were rejected (`CircularRefError`); there was no limit on the *total* number of expansions. A group containing N `` elements that point at another such group multiplies the work by N per nesting level, so a small document (about 1.4KB for five levels of ten) clones and renders over 100,000 nodes, consuming tens of seconds of CPU and hundreds of MiB of memory. Each additional level adds roughly 245 bytes and multiplies time by ~10 — the SVG `` analogue of the XML "billion laughs" attack. The fix introduces a `_UseExpansionCounter` shared across the document and any external SVGs it pulls in, capped at `MAX_USE_EXPANSIONS = 10000`; excess expansions are skipped and logged once, bounding CPU and memory. ## 2. Reproduction environment | service | image | role | | --- | --- | --- | | `svg-vuln` | `cve-2026-132275:vuln` | real svglib **2.3.0** (PyPI) | | `svg-fixed` | `cve-2026-132275:fixed` | real svglib **2.3.1** (vendor fix) | | `poc` | `cve-2026-132275-poc:local` | stdlib-only Python driver | A harness generates a `` bomb (configurable levels × fanout), calls the real `svglib.svg2rlg()` in a child process with a timeout, and reports elapsed time / completion. Both sides differ only in the svglib version. ## 3. Running the environment ```sh ./run-lab.sh build # installs svglib 2.3.0 / 2.3.1 from PyPI ./run-lab.sh up # cve132275lab network: svg-vuln / svg-fixed ./run-lab.sh sweep ./run-lab.sh down ``` ## 4. The PoC `poc/poc.py` (stdlib only): * **check** — exit 1 when the render exceeds the timeout (unbounded expansion), 0 on a fast capped render; 3 no worker, 2 unreachable/indeterminate. * **exploit** — narrated billion-laughs chain with a 6-level (1,000,000 expansion) bomb. * **probe** — scaling matrix: 3 levels (1000 expansions, fast on both) vs 5 levels (100,000, timeout on vulnerable / capped on fixed). * **mitigation** — 2.3.1 / `MAX_USE_EXPANSIONS`. A standalone full-chain exploit ships at `exploit/exploit.py`: ```sh python3 exploit/exploit.py --host=svg-vuln # exit 1 on confirmed unbounded expansion, 0 on a safe target ``` ## 5. Expected results | bomb | `svg-vuln` (2.3.0) | `svg-fixed` (2.3.1) | | --- | --- | --- | | 3 levels (1000 expansions) | 0.4s, completes | 0.4s, completes | | 5 levels (100,000 expansions, 1435 bytes) | **>12s timeout, unbounded** | 1.8s, capped | | 6 levels (1,000,000 expansions) | **timeout** | capped | | fixed log | — | `Too many expansions (limit is 10000)` | Captured runs: `evidence/check-*-run.txt`, `evidence/exploit-*-run.txt`, `evidence/probe-*-run.txt`, `evidence/mitigation-*-run.txt`, `evidence/exploit-standalone-run.txt`, `evidence/exploit-standalone-fixed-run.txt`, `evidence/fixed-limit-log.txt`, `evidence/versions.txt`, `evidence/0day-sweep.txt`. ## 6. Environment preconditions * Podman (or Docker); bounded containers on the isolated `cve132275lab` network. * Real-world impact requires a service that converts untrusted SVG with `svg2rlg()`; the payload is tiny and needs no external resources. ## 7. Additional findings (0-day sweep on the fixed line) The fixed line caps total `` expansions at `MAX_USE_EXPANSIONS` (10000), shared across the document and any external SVGs it pulls in; excess expansions are skipped and logged once. Small documents (1000 expansions) render normally on both builds; the exponential blow-up is bounded on the fixed line. No unbounded-expansion path remains. ## 8. Repository layout ``` README.md this write-up run-lab.sh environment driver (build / up / sweep / down) Makefile convenience targets poc/poc.py the PoC (check / exploit / probe / mitigation) exploit/exploit.py standalone full-chain exploit lab/lab.Dockerfile installs both upstream PyPI releases lab/harness.py generates the bomb, calls real svg2rlg, times it lab/service.py HTTP wrapper with child timeout (POST /render) evidence/ captured runs of every mode on both sides TRACKING.md excluded (working record) ``` ## 9. References * CVE record — https://www.cve.org/CVERecord?id=CVE-2026-132275 * GitHub advisory — https://github.com/deeplook/svglib/security/advisories/GHSA-555j-qj3j-c8jv * Fix commits — https://github.com/deeplook/svglib/commit/c4cddf3055e9e2ed4a4b5d05152f124f022e2d03 · https://github.com/deeplook/svglib/commit/f7ce0f0207b29ab68bd5dc2e2642dcc691737f69 * Fixed release — https://github.com/deeplook/svglib/releases/tag/v2.3.1