/

CVE-2026-104828

Severity:

HIGH RISK

(7.2)

Cross-Site Scripting (CWE-79) in HtmlUnit Neko Parser

CVE-2026-104828

Deferred

Vulnerability type

Category:

Cross-Site Scripting

CWE:

CWE-79

Impact:

Client-Side Code Execution

Severity:

HIGH RISK

(7.2)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

HtmlUnit Neko can serialize decoded character content from TEXTAREA and TITLE elements without restoring the required entity encoding. In applications that render the transformed output, attacker-controlled encoded text may become executable markup, enabling cross-site scripting when the parse-transform-serialize pipeline processes untrusted HTML.

HtmlUnit Neko can serialize decoded character content from TEXTAREA and TITLE elements without restoring the required entity encoding. In applications that render the transformed output, attacker-controlled encoded text may become executable markup, enabling cross-site scripting when the parse-transform-serialize pipeline processes untrusted HTML.

Affected context

The issue affects applications using HtmlUnit Neko in HTML sanitizers, content filters, or other workflows that parse and then serialize untrusted HTML. Risk is highest when content inside TEXTAREA or TITLE elements is accepted from an attacker and the serialized result is later rendered by a browser without an additional context-appropriate encoding or sanitization step.

The issue affects applications using HtmlUnit Neko in HTML sanitizers, content filters, or other workflows that parse and then serialize untrusted HTML. Risk is highest when content inside TEXTAREA or TITLE elements is accepted from an attacker and the serialized result is later rendered by a browser without an additional context-appropriate encoding or sanitization step.

Exploit preconditions

  • Attack surface: An HTML parse-and-serialize pipeline using HtmlUnit Neko
  • Required access: Ability to provide or influence HTML content processed by the application
  • Trigger point: Serialization of character content from TEXTAREA or TITLE elements
  • Rendering condition: The resulting HTML must be delivered to a browser or another markup interpreter
  • Why exploitation is possible: Entity references are decoded during parsing and emitted without the encoding needed to preserve their original text-only semantics
  • Attack surface: An HTML parse-and-serialize pipeline using HtmlUnit Neko
  • Required access: Ability to provide or influence HTML content processed by the application
  • Trigger point: Serialization of character content from TEXTAREA or TITLE elements
  • Rendering condition: The resulting HTML must be delivered to a browser or another markup interpreter
  • Why exploitation is possible: Entity references are decoded during parsing and emitted without the encoding needed to preserve their original text-only semantics

Why this happens

The underlying bug is an output-encoding failure in HTML serialization. HTMLWriterFilter treats TEXTAREA and TITLE content as special raw text while printCharacters() emits decoded characters without applying the entity encoding required for escapable raw-text elements. This maps to CWE-79: Improper Neutralization of Input During Web Page Generation, because attacker-influenced data can cross from a parsed document into browser-interpreted markup without adequate context-sensitive encoding.

The underlying bug is an output-encoding failure in HTML serialization. HTMLWriterFilter treats TEXTAREA and TITLE content as special raw text while printCharacters() emits decoded characters without applying the entity encoding required for escapable raw-text elements. This maps to CWE-79: Improper Neutralization of Input During Web Page Generation, because attacker-influenced data can cross from a parsed document into browser-interpreted markup without adequate context-sensitive encoding.

Potential impact

  • Attacker-controlled markup may execute in a victim's browser
  • Session data or other browser-accessible information could be exposed
  • User actions may be performed in the context of the affected application
  • Sanitizer or content-filter guarantees could be bypassed
  • Stored or reflected cross-site scripting impact could occur depending on how output is handled
  • Attacker-controlled markup may execute in a victim's browser
  • Session data or other browser-accessible information could be exposed
  • User actions may be performed in the context of the affected application
  • Sanitizer or content-filter guarantees could be bypassed
  • Stored or reflected cross-site scripting impact could occur depending on how output is handled

General mitigation guidance

Mitigation generally focuses on preserving text semantics throughout parsing and serialization and maintaining a strict trust boundary around untrusted HTML.

Common defensive patterns include:

  • Use a serializer that applies context-appropriate entity encoding for TEXTAREA, TITLE, and other escapable raw-text elements
  • Prefer allowlist-based HTML sanitization that validates the final serialized output
  • Encode untrusted data at the final browser output context rather than relying only on earlier parsing stages
  • Avoid rendering transformed HTML when a safer text representation or isolated document context is sufficient
  • Apply least privilege and appropriate browser isolation to reduce the impact of client-side compromise
  • Treat parse-transform-serialize libraries as security-sensitive components and validate their behavior with adversarial round-trip tests

Mitigation generally focuses on preserving text semantics throughout parsing and serialization and maintaining a strict trust boundary around untrusted HTML.

Common defensive patterns include:

  • Use a serializer that applies context-appropriate entity encoding for TEXTAREA, TITLE, and other escapable raw-text elements
  • Prefer allowlist-based HTML sanitization that validates the final serialized output
  • Encode untrusted data at the final browser output context rather than relying only on earlier parsing stages
  • Avoid rendering transformed HTML when a safer text representation or isolated document context is sufficient
  • Apply least privilege and appropriate browser isolation to reduce the impact of client-side compromise
  • Treat parse-transform-serialize libraries as security-sensitive components and validate their behavior with adversarial round-trip tests

How teams detect issues like this

Detection can combine implementation review, automated analysis, and runtime testing:

  • Search for serializers that emit parsed character data without context-sensitive entity encoding
  • Review handling of TEXTAREA, TITLE, script-like, and other raw-text or escapable raw-text elements
  • Add tests that compare input and output semantics for encoded characters across parse-and-serialize round trips
  • Inspect sanitizer pipelines for browser rendering of serialized output without a final validation or encoding stage
  • Enforce dependency and security review policies for libraries that transform untrusted HTML
  • Use automated static analysis or code review tools to flag unsafe HTML generation and missing output encoding

Detection can combine implementation review, automated analysis, and runtime testing:

  • Search for serializers that emit parsed character data without context-sensitive entity encoding
  • Review handling of TEXTAREA, TITLE, script-like, and other raw-text or escapable raw-text elements
  • Add tests that compare input and output semantics for encoded characters across parse-and-serialize round trips
  • Inspect sanitizer pipelines for browser rendering of serialized output without a final validation or encoding stage
  • Enforce dependency and security review policies for libraries that transform untrusted HTML
  • Use automated static analysis or code review tools to flag unsafe HTML generation and missing output encoding

Sources

SourceLink
github.comgithub.com/HtmlUnit/htmlunit-neko/commit/c165891e0753aef3e05f5daa6250d3e8d4ada3c0
github.comgithub.com/HtmlUnit/htmlunit-neko/releases/tag/5.4.0
github.comgithub.com/HtmlUnit/htmlunit-neko/security/advisories/GHSA-39xg-prhf-8785

Frequently asked

questions

It can be exploitable through a remotely supplied HTML document when an application processes attacker-controlled content and later renders the serialized result in a browser.

An attacker generally needs a way to submit or influence HTML that enters the affected parse-transform-serialize pipeline. Direct access to the server or library runtime is not necessarily required.

Preserve text semantics by using a serializer with correct context-sensitive entity encoding, then validate or sanitize the final HTML before browser rendering.

Treat serialized HTML as untrusted, test round-trip behavior for special elements, use allowlist-based sanitization, and enforce output-encoding and dependency-review checks in development pipelines.

It can be exploitable through a remotely supplied HTML document when an application processes attacker-controlled content and later renders the serialized result in a browser.

An attacker generally needs a way to submit or influence HTML that enters the affected parse-transform-serialize pipeline. Direct access to the server or library runtime is not necessarily required.

Preserve text semantics by using a serializer with correct context-sensitive entity encoding, then validate or sanitize the final HTML before browser rendering.

Treat serialized HTML as untrusted, test round-trip behavior for special elements, use allowlist-based sanitization, and enforce output-encoding and dependency-review checks in development pipelines.

Find out what's already
exploitable in your codebase.