VAITP Dataset

← Back to the dataset

CVE-2026-9769

Uncontrolled recursion in JustHTML parsing can cause a DoS via RecursionError.

  • CVSS 8.7
  • CWE-674
  • Resource Management
  • Remote

justhtml through 1.9.1 (fixed in 1.10.0) is vulnerable to uncontrolled recursion leading to denial of service. During JustHTML() construction, TreeBuilder.finish() unconditionally calls _populate_selectedcontent(), which recursively traverses the DOM tree via _find_elements()/_find_element() without a depth bound. An attacker who can supply HTML for parsing can provide deeply nested elements (e.g., ~1000 nested tags, roughly 11 KB) to exceed CPython's default recursion limit and trigger an unhandled RecursionError, which may abort parsing, fail requests, or terminate a worker/process depending on the host application's exception handling.

CVSS base score
8.7
Published
2026-08-23
OWASP
A04 Insecure Design
Orthogonal defect classification
Timing/Serialization
Code defect classification
Timing Issues
Category
Resource Management
Subcategory
Resource Exhaustion
Accessibility scope
Remote
Impact
Denial of Service (DoS)
Affected component
justhtml
Fixed by upgrading
Yes

Solution

Upgrade JustHTML to version 1.10.0 (or later) where the recursion issue is fixed.

Vulnerable code sample

import justhtml

def render(html: str) -> str:
    # VULNERABLE: uncontrolled recursion in JustHTML parsing
    parser = justhtml.JustHTML(html)
    return parser.render()

Patched code sample

import justhtml

def render(html: str) -> str:
    # FIX: limit recursion depth during parsing
    class SafeTreeBuilder(justhtml.parser.TreeBuilder):
        _MAX_DEPTH = 500
        def _populate_selectedcontent(self, element, depth=0):
            if depth > self._MAX_DEPTH:
                return  # abort deep traversal
            super()._populate_selectedcontent(element, depth + 1)

    original_builder = justhtml.parser.TreeBuilder
    justhtml.parser.TreeBuilder = SafeTreeBuilder
    try:
        parser = justhtml.JustHTML(html)
        return parser.render()
    finally:
        justhtml.parser.TreeBuilder = original_builder

Cite this entry

@misc{vaitp:cve20269769,
  title        = {{Uncontrolled recursion in JustHTML parsing can cause a DoS via RecursionError.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-9769},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-9769/}}
}

Download this entry as JSON Download the whole dataset

Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.