highVulnerability

GHSA-v7cf-c9rm-wm3j

### Summary justhtml through 1.9.1 allows denial of service via deeply nested HTML. During parsing, `JustHTML.__init__()` always reaches `TreeBuilder.finish()`, which unconditionally calls `_populate_selectedcontent()`. That function recursively traverses the DOM via `_find_elements()` / `_find_element()` without a depth bound, allowing attacker-controlled deeply nested input to trigger an unhandled `RecursionError` on CPython. Depending on the host application's exception handling, this can abort parsing, fail requests, or terminate a worker/process. ### Details `TreeBuilder.finish()` ([`treebuilder.py#L476`](https://github.com/EmilStenstrom/justhtml/blob/a866b6077770d9ec4cb6b6f9bfe7c918f98455e4/src/justhtml/treebuilder.py#L476)) unconditionally calls `_populate_selectedcontent(self.document)` at [line 494](https://github.com/EmilStenstrom/justhtml/blob/a866b6077770d9ec4cb6b6f9bfe7c918f98455e4/src/justhtml/treebuilder.py#L494). `_populate_selectedcontent()` ([`treebuilder.py#L1243`](https://github.com/EmilStenstrom/justhtml/blob/a866b6077770d9ec4cb6b6f9bfe7c918f98455e4/src/justhtml/treebuilder.py#L1243)) calls `_find_elements()` ([`treebuilder.py#L1280`](https://github.com/EmilStenstrom/justhtml/blob/a866b6077770d9ec4cb6b6f9bfe7c918f98455e4/src/justhtml/treebuilder.py#L1280)) to recursively search the DOM tree for `<select>` elements: ```python def _find_elements(self, node: Any, name: str, result: list[Any]) -> None: """Recursively find all elements with given name.""" if node.name == name: result.append(node) if node.has_child_nodes(): for child in node.children: self._find_elements(child, name, result) # recursive call ``` When the DOM tree depth exceeds CPython's default recursion limit (1000), this raises an unhandled `RecursionError`. The full call path is: `JustHTML(html)` → `tokenizer.run()` → `tree_builder.finish()` → `_populate_selectedcontent(document)` → `_find_elements(root, "select", selects)` (recursive)

Properties

ghsa_id
GHSA-v7cf-c9rm-wm3j
severity
high
summary
Uncontrolled recursion DoS in JustHTML() via deeply nested HTML
cve_id
GHSA-v7cf-c9rm-wm3j
is_ghsa_only
true
ghsa_published
2026-03-17T14:07:38Z
source_url
https://github.com/advisories/GHSA-v7cf-c9rm-wm3j
ghsa_updated
2026-03-17T14:07:39Z

Related Entities (3)

AFFECTS (1)

[Software]pip/justhtml

HAS_WEAKNESS (1)

[Weakness]Uncontrolled Recursion

REPORTED_BY (1)

[Source]GitHub Advisory Database

Explore deeper with Ninja Signal's threat intelligence graph

GHSA-v7cf-c9rm-wm3j — Ninja Signal Threat Intelligence | Ninja Signal