Incorrect handling of namespace boundaries during HTML rendering (GO-2026-6866)

Incorrect handling of namespace boundaries during HTML rendering (GO-2026-6866)

Description

Versions of golang.org/x/net/html before v0.62.0 do not check all ancestor namespace transitions when rendering nodes that mix HTML with other namespaces. As a result, parsing the rendered text again may produce a different interpretation from the original tree.

Potential impact

Applications that parse and check user input before rendering it as HTML may invalidate the assumptions behind their content checks. Depending on how a browser parses the output, unintended markup may result.

Remediation

Update golang.org/x/net to v0.62.0 or later. Do not assume that parsing and rendering HTML alone makes input safe. Validate the allowed elements and attributes, and apply protections appropriate to the output context.

Examples

The following examples show a dependency declaration in go.mod.

Before

go
require golang.org/x/net v0.61.0

After

go
require golang.org/x/net v0.62.0

Update go.sum, then rebuild with the fixed module and deploy.

References