GHSA-4WXF-43CV-CFXX
A CSS length in a style attribute drives an unbounded string allocation
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-4WXF-43CV-CFXX divulgada | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
`get_text()` runs on untrusted HTML under the default config, and it's the documented way to
use inscriptis. A CSS length in a `style` attribute on a block element gets turned into an
integer and then used straight away as a repeat count for the string inscriptis emits, with no
upper bound. So a ~40 byte document can force a multi-gigabyte allocation and take the process
down with a `MemoryError`.
Proof of concept
Installed from PyPI with `pip install inscriptis==2.7.4`:
from inscriptis import get_text
get_text('<p style="margin-top:2000000000em">x</p>')The value goes through `CssParse._get_em`, which returns `round(2000000000)` untouched, into
`Canvas.open_block`, which runs `"\n" * (required_newlines - 1)` and tries to build a two
billion character string. Under a 1 GiB address-space limit that raises `MemoryError`; with no
limit it eats all the host memory.
Output length just tracks the number in the style value, so it scales with the digits you type
rather than the size of the input:
<p style="margin-top:10000000em">x</p> -> ~10 MB output, 38 byte input
<p style="margin-top:2000000000em">x</p> -> ~2 GB attempt, 40 byte inputImpact
Anything that runs `get_text()` or `get_annotated_text()` on HTML it doesn't control can be
crashed by one small request, no auth needed. Converting scraped or user-submitted HTML is what
the library is for, so that input is untrusted by default.
`margin-top`, `margin-bottom`, `padding-left` and the `margin-before`/ `padding-start` aliases
all reach the same spot. Units other than `em`/ `rem`/ `qem` get divided by 8 but still allocate
at the same order of magnitude.
Issue #63 added `suppress(ValueError)` around these handlers, so a malformed value is caught, but
a valid oversized one isn't. As far as I can see `_get_em` has never capped the magnitude.
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
PyPIinscriptis |
Sin parche | — | — | — |
Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/weblyzard/inscriptis/security/advisories/GHSA-4wxf-43cv-cfxxLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
