CVE-2023-2798

Denial of Service
Affects
HtmlUnit
in
HtmlUnit
No items found.
Versions
<2.70.0

Patch Available.

Exclamation circle icon
Patch Available

This Vulnerability has been fixed in the Never-Ending Support (NES) version offered by HeroDevs.

Overview

HtmlUnit is a browser library for Java programs that operates without a graphical interface. It models HTML documents and lets applications load pages, fill forms, follow links, and execute JavaScript with configurable browser behavior. It is used for automated web testing and retrieving information from websites.

A denial of service vulnerability (CVE-2023-2798) has been identified in HtmlUnit's DOM node implementation, which allows attackers to crash HtmlUnit with a stack overflow by supplying a page with a very deeply nested element tree. Applications that use HtmlUnit to load untrusted web pages can be made unavailable this way.

Per OWASP: The Denial of Service (DoS) attack is focused on making a resource (site, application, server) unavailable for the purpose it was designed.

This issue affects all versions of HtmlUnit before 2.70.0.

Details

Module Info

Vulnerability Info

This High-severity vulnerability is found in the net.sourceforge.htmlunit:htmlunit package in all versions of HtmlUnit before 2.70.0. Several methods of com.gargoylesoftware.htmlunit.html.DomNode walk up the DOM tree by recursion, adding one Java stack frame for every ancestor of the node they start from.

When a node is added, removed, or has its character data changed, HtmlUnit notifies listeners on that node and then calls the same method on the parent node:

protected void fireNodeAdded(final DomChangeEvent event) {
    final List<DomChangeListener> listeners = safeGetDomListeners();
    if (listeners != null) {
        for (final DomChangeListener listener : listeners) {
            listener.nodeAdded(event);
        }
    }
    if (parent_ != null) {
        parent_.fireNodeAdded(event);
    }
}

fireNodeDeleted and fireCharacterDataChanged follow the same pattern. The descendant element iterator used to walk a subtree also climbs back up the tree recursively when a branch has no further siblings:

private DomNode getNextElementUpwards(final DomNode startingNode) {
    if (startingNode == DomNode.this) {
        return null;
    }
    final DomNode parent = startingNode.getParentNode();
    if (parent == null || parent == DomNode.this) {
        return null;
    }
    DomNode next = parent.getNextSibling();
    while (next != null && !isAccepted(next)) {
        next = next.getNextSibling();
    }
    if (next == null) {
        return getNextElementUpwards(parent);
    }
    return next;
}

The recursion depth is bounded only by the nesting depth of the document, which the page author controls. A page that nests elements deeply enough makes HtmlUnit exhaust the thread's stack while it parses or modifies the page, and the resulting StackOverflowError aborts processing. An attacker who can get an HtmlUnit-based application to load such a page can crash it repeatedly and deny service to legitimate users.

Mitigation

HtmlUnit security fixes are made on the current development branch on a best-effort basis. Older releases should be migrated to a current release that contains the fix. For more information, see here.

Users of the affected components should apply one of the following mitigations:

  • Upgrade affected applications to a current version of HtmlUnit that contains the fix.
  • Leverage a commercial support partner like HeroDevs for post-EOL security support.
Vulnerability Details
Severity
Level
CVSS Assessment
Low
>=0 <4
Medium
>=4 <6
High
>=6 <8
Critical
>=8 <10
High
ID
CVE-2023-2798
PROJECT Affected
HtmlUnit
Versions Affected
<2.70.0
NES Versions Affected
Published date
November 5, 2026
≈ Fix date
November 5, 2026
Category
Denial of Service
Vex Document
Download VEXHow do I use it?
Sign up for the latest vulnerability alerts fixed in
NES for HtmlUnit
Rss feed icon
Subscribe via RSS
or

By submitting the form I acknowledge receipt of our Privacy Policy.

Thanks for signing up for our Newsletter! We look forward to connecting with you.
Oops! Something went wrong while submitting the form.