llamaCVEVulnerability Intelligence
/
Advisory · GitHub · PyPI · justhtml

GHSA-GJF2-F4JC-69XF

Default sanitizer bypass: <selectedcontent> projection re-inserts unsanitized subtree (plus two availability findings)

Parche disponible
Descargar PNG JSON
CVSS
—
high
Fuente: —
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
Parche1 versiónPrimer parche el mismo día de la divulgación
Exposición106 dDesde la divulgación, 6 ago 2026, 6:17 p. m.
Detección103 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 la severidad declarada por GHSA (alta) y la evidencia de explotación (sin evaluación oficial): sin explotación conocida, no automatizable e impacto técnico parcial. Hay versiones corregidas disponibles.
Si sale un exploit, la subo de categoría. Atento.Ponle una regla en tu SIEM y seguimos.
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Explotación
Remediación
Parche 3.11.0
Monitoreo
Detectada +1
6 ago 26
18 nov 26
21 nov 26
6 ago 26
2 sept 26
29 sept 26
25 oct 26
21 nov 26
FechaFaseEventoDetalle
Divulgación Publicada GHSA-GJF2-F4JC-69XF divulgada
Remediación Parche 3.11.0 justhtml · 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

Hi Emil,

Three findings in v3.10.1, reported privately per `SECURITY.md`. The first is a bypass of
the default sanitizer and is the reason this is a private report rather than an issue.

1. Default sanitizer bypass via `<selectedcontent>` projection (critical)

`JustHTML(html).to_html()` — the documented safe default — emits attacker-controlled
SVG/MathML with event handlers intact.

from justhtml import JustHTML
P = "<select><selectedcontent><option><svg onload=X>"
JustHTML(P).to_html(pretty=False)
# '<html><head></head><body><svg onload="X"></svg></body></html>'
JustHTML(P, fragment=True).to_html(pretty=False)
# '<svg onload="X"></svg>'

Same result through the CLI with no flags:

$ printf '<select><selectedcontent><option><svg onload=X>' | python -m justhtml -
<svg onload="X"></svg>

`<svg onload>` executes in every current browser, so any application doing
`JustHTML(untrusted).to_html()` has stored/reflected XSS.

These controls isolate it to the fused safe-engine plan, not to the policy:

| path | output |
|---|---|
| `JustHTML(P, transforms=[Sanitize()])` (raw plan + transform) | `<body></body>` ✅ |
| `JustHTML("<select><option><svg onload=X>")` (no marker) | `<body></body>` ✅ |
| `JustHTML(P)` (default fused plan) | `<svg onload="X">` ❌ |

Cause. `use_compiled_safe_engine` (`parser/__init__.py:179`) is the default, and that
plan defers removal: disallowed nodes are recorded in `_nodes_to_drop` /
`_nodes_to_unwrap` (`engine.py:4212-4222`) and cleared afterwards. But `parse()` orders
the passes like this:

self._parse_range(0, self._length)
...
if self._has_selectedcontent:  self._project_selectedcontent()   # engine.py:1695
if self._nodes_to_drop:        self._drop_recorded_nodes()       # engine.py:1697
if self._nodes_to_unwrap:      self._unwrap_recorded_nodes()     # engine.py:1699

`_project_selectedcontent` does `clone = child.clone_node(deep=True)` followed by
`self._append(marker, clone)` (`engine.py:6118-6121`). Those clones are **new node
objects that are in neither deferred list**, so the sanitization passes that run
immediately after never see them, and the raw subtree is reinstated into the output.

HTML-namespace attributes are still stripped (they were projected during the scan), but
foreign elements keep every attribute verbatim. A sweep of 2100 shape combinations
produced 7 distinct violation signatures, including:

| inner content | sanitized output body |
|---|---|
| `<svg onload=X>` | `<svg onload="X"></svg>` |
| `<svg><animate attributeName=x>` | `<svg><animate attributeName="x"></animate></svg>` |
| `<math href=javascript:X>` | `<math href="javascript:X"></math>` |
| `<math><annotation-xml encoding=text/html><b onclick=X>` | `<math><annotation-xml encoding="text/html">…` |

The last one re-creates an HTML integration point in the output.

This sits inside the `SECURITY.md` threat model rather than any carve-out: §2 promises
"`JustHTML(html)` sanitizes by default" and "The default policy blocks event handler
attributes and executable tags", and §8 extends that to the CLI. It is not
`sanitize=False`, not a post-`Sanitize` transform, and not a permissive custom allowlist.

I checked this against the published advisories — the nearest,
`GHSA-r758-8hxw-4845`, states it "does not affect the default safe configuration" and
was fixed in 1.14.0, so this looks distinct. There is no `selectedcontent` case in
`tests/justhtml-sanitize-tests/cases.json`, and every `selectedcontent` test in
`tests/test_parser_tree.py` runs with `sanitize=False`, which is why the suite is green.

Two directions for a fix, whichever fits the engine's design better: move
`_project_selectedcontent()` to after the drop/unwrap passes, or register each appended
clone into `_nodes_to_drop`/`_nodes_to_unwrap` as it is created. Either way it is worth
pinning both directions — that the projected content is sanitized, *and* that legitimate
projection still happens.

2. Quadratic time and memory in the same projection (high)

The deep clone is per marker, so cost is `markers × option_size` from an input of
`markers + option_size`:

html = "<select><option selected>" + "<b>x</b>"*n + "</option>" \
     + "<selectedcontent></selectedcontent>"*n + "</select>"
JustHTML(html)

| n | input | parse | peak RSS |
|---|---|---|---|
| 250 | 10.5 KB | 60 ms | 46 MB |
| 500 | 21.0 KB | 265 ms | 114 MB |
| 1000 | 42.0 KB | 1310 ms | 394 MB |
| 2000 | 84.0 KB | 2834 ms | 1564 MB |

84 KB of untrusted HTML → ~2.8 s of CPU and ~1.5 GB resident, roughly 4× per
doubling in both dimensions.

The existing guard at `tests/test_parser_engine.py:87`
(`test_deep_selectedcontent_projection_scales_linearly`) holds the option content at a
single character and scales only the marker count, so it measures the one factor that is
linear and misses the product.

This is the availability half of the §1 boundary — *"Small hostile inputs must not
trigger disproportionate work"* — and it is the same function as finding 1, so it
probably wants the same patch.

3. `to_markdown()` nested-blockquote prefixing is super-quadratic (medium)
html = "<blockquote>"*n + "<p>x</p>"*n
JustHTML(html).to_markdown()

| n | input | `to_markdown()` | `to_html(pretty=True)` on the same tree | output |
|---|---|---|---|---|
| 250 | 4.9 KB | 43 ms | 0.8 ms | 0.24 MB |
| 500 | 9.8 KB | 186 ms | 1.5 ms | 0.95 MB |
| 1000 | 19.5 KB | 1113 ms | 3.5 ms | 3.81 MB |
| 2000 | 39.1 KB | 8060 ms | — | 15.26 MB |
| 4000 | 78.1 KB | 69660 ms | — | 61.04 MB |

78 KB → ~70 s, against 12.9 ms for the HTML pretty-printer on the identical tree.
Both `blockquote` and `p` are in the default allowlist, so this survives sanitization
untouched. Growth is ~8× per doubling because each nesting level re-splits and re-copies
the whole accumulated inner output:

# serializer/markdown.py:498-509  (after_blockquote)
text = inner_builder.finish()
for line in text.split("\n"):
    parent_builder.raw("> ")
    parent_builder.raw(line)

`SECURITY.md` §4 already makes this exact promise for pretty HTML — *"avoids repeatedly
copying nested output, so deeply nested input does not cause disproportionate work"* —
and commits `d9d4969` / `6c28883` implemented it there. The markdown serializer looks
like it never got the equivalent guard, and there is no `assert_scales_linearly`
coverage for it. Depth alone is quadratic as well (1.5 MB input → 4.4 s).

If you would rather triage this one in the open, I am happy to move it to a public issue
— I have kept it here only because `SECURITY.md` asks for all suspected vulnerabilities
to go private first.

---

I have not opened any public issue or PR for any of these, and I will hold until you have
had a chance to look. Happy to send a patch for any or all of them if that is useful —
just say which direction you prefer for finding 1, since it is an ordering choice inside
the engine rather than an obvious one-liner.

*Disclosure: found with AI assistance (Claude Code). Every repro in this report was
executed against v3.10.1 locally and the outputs above are the real captured results.*

Versiones

Rangos afectados

Afectada Corregida Última
justhtml≤ 3.10.1
3.10.1
3.17.0
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
pypijusthtml
Corregida 3.11.0 0 d 3.17.0 no afectada
Versiones corregidas3.11.0
Explotación

Arsenal público

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

Referencias
Advisoryhttps://github.com/EmilStenstrom/justhtml/security/advisories/GHSA-gjf2-f4jc-69xf

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