8.7high
justhtml before 1.18.0 Denial of Service via CSS Selector
- Severity
- 8.7high CVSS:4.0 by VulnCheck
- Exploit likelihood
- 0.65% (higher than 46% of CVEs)
- Published
- Last changed
- Assigned by
- VulnCheck
- Also known as
- GHSA-r8cj-3554-33mr
Description
justhtml before 1.18.0 contains multiple low-severity denial-of-service issues in CSS selector handling and linkification. Applications that evaluate attacker-controlled selector strings (via query(), matches(), or selector-based transforms), run selector matching over very large untrusted documents, construct DOM trees from untrusted structure, or enable linkification over attacker-controlled text may consume disproportionate CPU or memory. Triggers include oversized selectors, large selector lists, oversized compound selectors, long combinator chains, deeply nested functional pseudo-classes, repeated token/positional matching, cyclic DOM graphs causing non-terminating traversal, and punctuation-heavy or trailing-bracket linkification input. These are availability-only concerns and do not by themselves allow script execution, data disclosure, or sanitizer bypass. Default JustHTML(sanitize=True) usage is not expected to be exposed, since selectors are normally supplied by application code.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| EmilStenstrom justhtml | before 1.18.0 Not affected: 1.18.0 | CVE List |
| justhtml (PyPI) | before 1.18.0 | GitHub Advisory Database |
All scores
| VulnCheck | 8.7high CVSS:4.0 | CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N |
| VulnCheck | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
| GitHub | low rating |
Classification
What each source says
CVE List
justhtml before 1.18.0 contains multiple low-severity denial-of-service issues in CSS selector handling and linkification. Applications that evaluate attacker-controlled selector strings (via query(), matches(), or selector-based transforms), run selector matching over very large untrusted documents, construct DOM trees from untrusted structure, or enable linkification over attacker-controlled text may consume disproportionate CPU or memory. Triggers include oversized selectors, large selector lists, oversized compound selectors, long combinator chains, deeply nested functional pseudo-classes, repeated token/positional matching, cyclic DOM graphs causing non-terminating traversal, and punctuation-heavy or trailing-bracket linkification input. These are availability-only concerns and do not by themselves allow script execution, data disclosure, or sanitizer bypass. Default JustHTML(sanitize=True) usage is not expected to be exposed, since selectors are normally supplied by application code.
GitHub Advisory Database
Summary
justhtml 1.18.0 fixes multiple low-severity denial-of-service hardening issues in CSS selector handling and linkification.
These issues are availability concerns. They do not allow script execution, data disclosure, or sanitizer bypass by themselves.
Affected versions
justhtml< 1.18.0
Fixed version
justhtml1.18.0released on May 4, 2026
Impact
CSS selector handling
Applications that evaluate attacker-controlled selector strings, or that run selector-based transform pipelines over attacker-controlled documents, could consume disproportionate CPU or memory.
The affected selector patterns included oversized selectors, large selector lists, oversized compound selectors, long combinator chains, deeply nested functional pseudo-classes such as :not(...), repeated attribute/class token matching over large values, repeated sibling or ancestor scans, repeated positional pseudo-class work, and :contains(...) over large descendant text.
Programmatically constructed malformed DOM graphs could also trigger non-terminating or duplicate traversal in some selector paths, including cyclic/shared child graphs, cyclic parent chains, and cyclic text traversal for :contains(...).
Linkification
Attacker-controlled text containing punctuation-heavy input or URL candidates ending in long runs of unmatched closing brackets could cause repeated rescanning and consume disproportionate CPU when linkification was enabled.
Default configuration
Ordinary sanitization of parsed HTML with the default JustHTML(..., sanitize=True) configuration is not expected to expose untrusted users to selector injection, because selectors are normally supplied by application code.
The main risk areas are:
- applications that accept selector strings from untrusted users and pass them to
query(...),matches(...), or selector-based transforms - custom transform or sanitization pipelines that run selector matching over very large untrusted documents
- applications that construct or mutate DOM trees programmatically from untrusted structure
- applications that enable
Linkify(...)over attacker-controlled text
Fixes in 1.18.0
1.18.0 adds generalized selector resource controls and removes several repeated-work hot paths:
- shared selector limits for parse and match operations
- structural caps for selector length, selector lists, compound selectors, complex selectors, and parse depth
- match-operation and string-byte budgets
- per-query matcher state for caches and cycle guards
- precomputed or cached ancestor, sibling, positional, attribute-token, text-content,
:not(...),:empty, and:nth-child(...)work - consistent enforcement across public parsing,
query(...), tag-only query fast paths, transform selector compilation, and sanitization transform matching - linkification hardening for punctuation-heavy inputs and trailing bracket trimming
CWE mapping
- CWE-400: Uncontrolled Resource Consumption
- CWE-407: Inefficient Algorithmic Complexity
- CWE-835: Loop with Unreachable Exit Condition
Recommended action
Upgrade to justhtml 1.18.0.
If users cannot upgrade immediately:
- do not pass untrusted selector strings to
query(...),matches(...), or selector-based transforms - restrict the size of untrusted documents before selector matching or linkification
- avoid constructing programmatic DOM graphs from untrusted structure
- avoid enabling
Linkify(...)on very large attacker-controlled text
Credit
Discovered during an internal security review of justhtml.
NVD (es)
justhtml anterior a la versión 1.18.0 contiene múltiples problemas de denegación de servicio de baja gravedad en el manejo de selectores CSS y la linkificación. Las aplicaciones que evalúan cadenas de selectores controladas por el atacante (a través de query(), matches() o transformaciones basadas en selectores), ejecutan la coincidencia de selectores sobre documentos no confiables muy grandes, construyen árboles DOM a partir de estructuras no confiables, o habilitan la linkificación sobre texto controlado por el atacante pueden consumir una cantidad desproporcionada de CPU o memoria. Los desencadenantes incluyen selectores de tamaño excesivo, listas de selectores grandes, selectores compuestos de tamaño excesivo, cadenas de combinadores largas, pseudoclases funcionales profundamente anidadas, coincidencia repetida de tokens/posicional, gráficos DOM cíclicos que causan un recorrido no terminante, y entrada de linkificación con mucha puntuación o corchetes finales. Estas son preocupaciones solo de disponibilidad y no permiten por sí mismas la ejecución de scripts, la divulgación de datos o la omisión del saneador. El uso predeterminado de JustHTML(sanitize=True) no se espera que esté expuesto, ya que los selectores son normalmente proporcionados por el código de la aplicación.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-4671 changed 2026-08-24 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-r8cj-3554-33mr changed 2026-08-24 | CC-BY-4.0 |
| NVD | CVE-2026-4671 changed 2026-10-12 | Public domain |