Skip to main content
Vulnerability Database/CVE-2026-104828

CVE-2026-104828: HtmlUnit Neko HTML Parser XSS Vulnerability

CVE-2026-104828 is a cross-site scripting flaw in HtmlUnit Neko that allows attackers to inject malicious scripts through improperly encoded HTML elements. This post covers technical details, affected versions, and mitigation steps.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2026-104828 Overview

CVE-2026-104828 is a cross-site scripting (XSS) vulnerability in HtmlUnit Neko, an HtmlUnit adaptation of the NekoHTML parser. Versions prior to 5.4.0 fail to entity-encode decoded character content inside TEXTAREA and TITLE elements when serializing parsed HTML. The HTMLWriterFilter class treats both elements as special content, so entity references decoded during parsing are later emitted as raw markup by printCharacters(). Applications that use htmlunit-neko in HTML sanitizers, content filters, or parse-transform-serialize pipelines can convert attacker-controlled encoded text into executable markup when a browser renders the output. The issue is tracked under [CWE-79] and is fixed in version 5.4.0.

Critical Impact

Attackers can bypass HTML sanitizers built on htmlunit-neko and inject executable script into pages rendered by downstream browsers.

Affected Products

  • HtmlUnit Neko versions prior to 5.4.0
  • Applications embedding htmlunit-neko as an HTML sanitizer or content filter
  • Parse-transform-serialize pipelines consuming untrusted HTML through htmlunit-neko

Discovery Timeline

  • 2026-10-15 - CVE-2026-104828 published to the National Vulnerability Database (NVD)
  • 2026-10-21 - Last updated in NVD database

Technical Details for CVE-2026-104828

Vulnerability Analysis

The flaw lives in HTMLWriterFilter.java within htmlunit-neko. The filter sets a normalize_ flag that controls whether character data is entity-encoded on serialization. Prior to 5.4.0, the filter disables normalization for any element flagged as isSpecial(), which includes TEXTAREA and TITLE. Both are escapable raw-text elements under the HTML specification, meaning the parser decodes entity references inside them but the serializer must re-encode <, >, and & on output.

Because printCharacters() emits the already-decoded buffer verbatim, a round-trip through the parser rewrites <script>alert(1)</script> as literal <script>alert(1)</script> once the enclosing TEXTAREA or TITLE tag is stripped or altered downstream. Sanitizers that trust the serialized output pass the resulting markup to browsers, producing stored or reflected XSS.

Root Cause

The root cause is overly broad use of the isSpecial() predicate to control output normalization. TEXTAREA and TITLE require different handling from SCRIPT, STYLE, PLAINTEXT, and XMP: their character content must be entity-encoded on serialization even though the parser treats them as raw text during tokenization.

Attack Vector

An attacker submits HTML containing entity-encoded script payloads wrapped in TEXTAREA or TITLE tags. When a sanitizer parses and re-serializes the input using htmlunit-neko, the decoded payload becomes raw markup. If the downstream pipeline removes the outer element, strips attributes, or embeds the serialized fragment in a different DOM context, the browser executes the previously inert content.

java
// Patch excerpt: HTMLWriterFilter.java
// Source: https://github.com/HtmlUnit/htmlunit-neko/commit/c165891e0753aef3e05f5daa6250d3e8d4ada3c0
        throws XNIException {
        seenRootElement_ = true;
        elementDepth_++;
-        normalize_ = !htmlElements_.getElement(element.getRawname()).isSpecial();
+
+        final int elementCode = htmlElements_.getElement(element.getRawname()).code;
+        normalize_ = HTMLElements.PLAINTEXT != elementCode
+                        && HTMLElements.SCRIPT != elementCode
+                        && HTMLElements.STYLE != elementCode
+                        && HTMLElements.XMP != elementCode;
+
        printStartElement(element, attributes, false);
        super.startElement(element, attributes, augs);
    }

The patch replaces the generic isSpecial() check with an explicit allowlist of elements whose character data must remain unencoded. TEXTAREA and TITLE now fall through to the normalizing path, so entity references survive the round trip.

Detection Methods for CVE-2026-104828

Indicators of Compromise

  • HTTP request bodies or form fields containing entity-encoded script payloads inside <textarea> or <title> tags, especially <script>, <img, or <svg sequences.
  • Serialized HTML output from backend sanitizers that contains raw <script> or event-handler attributes inside or adjacent to TEXTAREA or TITLE elements.
  • Content Security Policy (CSP) violation reports from downstream applications referencing inline script execution after sanitizer processing.

Detection Strategies

  • Scan Java dependency manifests (pom.xml, build.gradle, MANIFEST.MF) for net.sourceforge.htmlunit:neko-htmlunit or org.htmlunit:neko-htmlunit at versions below 5.4.0.
  • Add regression tests that round-trip <textarea><script>alert(1)</script></textarea> through the sanitizer and assert that <script> does not appear in the serialized output.
  • Instrument sanitizer pipelines with output-diff logging to catch cases where decoded entity content differs between parser input and serializer output.

Monitoring Recommendations

  • Monitor web application firewall (WAF) logs for repeated entity-encoded tag patterns targeting fields that accept rich text.
  • Track browser-side CSP reports and JavaScript error telemetry for unexpected inline script execution on pages rendering sanitized user content.
  • Enable dependency-scanning tools in CI/CD to flag future reintroductions of htmlunit-neko versions prior to 5.4.0.

How to Mitigate CVE-2026-104828

Immediate Actions Required

  • Upgrade htmlunit-neko to version 5.4.0 or later across all services that parse or sanitize untrusted HTML.
  • Audit application code for direct use of HTMLWriterFilter and confirm the fix is on the active classpath.
  • Rebuild and redeploy artifacts that bundle htmlunit-neko transitively, including shaded JARs and container images.

Patch Information

The fix is published in GitHub Release Version 5.4.0 and committed in GitHub Commit c165891. Full technical details are documented in GitHub Security Advisory GHSA-39xg-prhf-8785.

Workarounds

  • Post-process serialized output to re-encode <, >, and & inside any TEXTAREA or TITLE element before passing HTML to downstream renderers.
  • Strip TEXTAREA and TITLE elements from attacker-controlled input prior to serialization if the application does not require them.
  • Apply a strict Content Security Policy that blocks inline script execution to limit exploitation impact until the patch is deployed.
bash
# Maven dependency upgrade
mvn versions:use-dep-version \
  -Dincludes=org.htmlunit:neko-htmlunit \
  -DdepVersion=5.4.0 \
  -DforceVersion=true

# Gradle equivalent
# implementation 'org.htmlunit:neko-htmlunit:5.4.0'

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.