Denial of Service Vulnerability in JustHTML Package Due to Uncontrolled Recursion

justhtml Updated 17 Mar 2026

Summary

17/03/2026
HIGH
Yes i
High
7.1

GHSA-v7cf-c9rm-wm3j: Uncontrolled recursion DoS in JustHTML() via deeply nested HTML. Affects justhtml versions < 1.10.0. Fixed in 1.10.0. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

JustHTML is a Python library designed for parsing and manipulating HTML documents. It provides a simple interface for converting HTML to various formats and allows users to traverse and modify the DOM tree. However, versions up to 1.9.1 are vulnerable to a denial of service (DoS) attack through deeply nested HTML structures, which can lead to unhandled recursion errors during parsing.

Vulnerability Detail

The vulnerability arises from the JustHTML library's handling of deeply nested HTML elements. Specifically, the TreeBuilder.finish() method calls _populate_selectedcontent(), which in turn invokes _find_elements() recursively without a depth limit. This can lead to a RecursionError when the depth of the DOM tree exceeds CPython's default recursion limit of 1000. An attacker can exploit this by supplying HTML with excessive nesting, causing the application to crash or terminate unexpectedly. The vulnerability affects multiple recursive functions within the library, making it a significant risk for applications relying on JustHTML for HTML parsing.

How To Fix

Minimum fixed version

1.10.0

This is the first release that contains the fix.

pip install --upgrade "justhtml==1.10.0"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

If immediate updating is not possible, consider implementing exception handling in your application to catch RecursionError exceptions during the parsing process. This can prevent the application from crashing, although it does not eliminate the underlying vulnerability. Here is an example of how to handle the exception:

try: doc = JustHTML(html) except RecursionError: print('Recursion limit exceeded. Please provide less nested HTML.')

Conclusion

The JustHTML library is vulnerable to a denial of service attack due to uncontrolled recursion in its HTML parsing methods. Users are strongly advised to update to version 1.10.0 or later to mitigate this risk. Implementing exception handling can serve as a temporary workaround while transitioning to the patched version.

See every vulnerability recorded for justhtml →

Share this vulnerability

FAQ

The CVSS score of this vulnerability is 7.1, indicating a high severity level.

Versions of JustHTML up to and including 1.9.1 are affected by this vulnerability.

You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.

Implement exception handling in your application to manage RecursionError exceptions during parsing as a temporary workaround.

The denial of service attack occurs when an attacker supplies deeply nested HTML, causing the application to exceed the recursion limit and crash.

Related vulnerabilities

Recent vulnerabilities recorded for justhtml.

How To Fix

Minimum fixed version

1.10.0

This is the first release that contains the fix.

pip install --upgrade "justhtml==1.10.0"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback