Excessive resource use when merging HTML text nodes (GO-2026-6860)

Excessive resource use when merging HTML text nodes (GO-2026-6860)

Description

In versions before v0.62.0, golang.org/x/net/html repeatedly copies the accumulated string when merging adjacent text nodes. Processing HTML that repeats short text runs and ignored end tags can cause processing time and memory allocations to grow rapidly relative to the input size.

Potential impact

Services that parse untrusted HTML may consume excessive CPU and memory, delaying request processing or interrupting the service.

Remediation

Update golang.org/x/net to v0.62.0 or later. Also limit the size of HTML input and the number of concurrent processing tasks.

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