Skip to main content
CVE Vulnerability Database
Vulnerability Database/CVE-2025-58189

CVE-2025-58189: Golang Go XSS Vulnerability

CVE-2025-58189 is an XSS flaw in Golang Go where ALPN negotiation errors expose unescaped attacker-controlled data. This post covers the technical details, affected versions, security impact, and mitigation.

Published:

CVE-2025-58189 Overview

CVE-2025-58189 affects the Go standard library's crypto/tls package. When Conn.Handshake fails during Application-Layer Protocol Negotiation (ALPN), the returned error embeds the attacker-controlled ALPN protocol strings sent by the client without escaping them. Applications that log these errors to files or terminals may render unescaped control characters, enabling log injection and terminal manipulation.

The issue is tracked as GO-2025-4008 and categorized under [CWE-532] Insertion of Sensitive Information into Log File. It is exploitable over the network without authentication or user interaction, but its impact is limited to information integrity in logs and consoles.

Critical Impact

Remote unauthenticated clients can inject arbitrary bytes, including terminal escape sequences, into server logs by supplying crafted ALPN protocol identifiers during a failing TLS handshake.

Affected Products

  • Golang Go standard library crypto/tls package
  • Go-based TLS servers that log handshake errors
  • Applications using tls.Conn.Handshake with ALPN configured

Discovery Timeline

  • 2025-10-29 - CVE-2025-58189 published to NVD
  • 2026-06-17 - Last updated in NVD database

Technical Details for CVE-2025-58189

Vulnerability Analysis

The vulnerability resides in the ALPN negotiation path of Go's TLS handshake implementation. When a client presents ALPN protocol identifiers that the server cannot match, Conn.Handshake returns an error message that concatenates the client-supplied protocol strings directly into the error text. The protocol strings are not sanitized or escaped.

Downstream code that writes the error to structured or unstructured logs will emit the raw bytes. An attacker controlling the ALPN list can therefore inject newlines, ANSI escape sequences, or fake log entries into any sink that consumes the handshake error, including systemd journals, log files, SIEM pipelines, and operator terminals.

The issue is limited to confidentiality of the log stream. It does not allow code execution, memory corruption, or bypass of TLS authentication. Details are documented in the Go Issue Tracker Entry and the Golang Announce group.

Root Cause

The root cause is missing output encoding on untrusted client data before it is used to construct an error string. ALPN protocol identifiers are opaque byte strings under attacker control during the ClientHello. The Go TLS code embeds them into a formatted error without applying %q quoting or byte filtering.

Attack Vector

An unauthenticated remote attacker initiates a TLS connection to a Go-based server. The attacker crafts a ClientHello containing ALPN protocol values that will not match the server's configured protocols and that include newline or ANSI escape bytes. The handshake fails, the server logs the error, and the injected bytes reach the log destination verbatim.

No synthetic proof-of-concept code is included here. Refer to the Go.dev Code Review for the patch and to the Openwall OSS Security Discussion for community analysis.

Detection Methods for CVE-2025-58189

Indicators of Compromise

  • Log lines containing control characters (\\x1b, \r, \n) sourced from TLS handshake error messages
  • Handshake error entries referencing unexpected or non-printable ALPN protocol names
  • Log entries where a single TLS error appears to span multiple lines or overwrite prior content

Detection Strategies

  • Search structured logs for TLS handshake failures containing byte values outside the printable ASCII range within ALPN-related fields
  • Alert on repeated failed handshakes from the same source IP where the error text includes escape sequences
  • Diff parsed log timestamps against line counts to identify multi-line injections from a single connection event

Monitoring Recommendations

  • Route Go application logs through a pipeline that escapes or strips non-printable characters before storage
  • Correlate TLS error rates with source IP reputation feeds to surface probing activity
  • Baseline expected ALPN protocol identifiers per service and flag deviations for review

How to Mitigate CVE-2025-58189

Immediate Actions Required

  • Upgrade Go to a version that includes the fix referenced in Go.dev Code Review 707776 and rebuild all affected binaries
  • Audit application log sinks and terminal viewers for handling of untrusted bytes originating from TLS errors
  • Inventory Go-based services exposing TLS endpoints with ALPN enabled

Patch Information

The Go team addressed the issue by escaping attacker-controlled ALPN data in the handshake error path. Consult the Go Vulnerability Advisory GO-2025-4008 for the fixed version list, and apply the upstream patch via go get or by upgrading the toolchain and recompiling dependent binaries.

Workarounds

  • Wrap TLS handshake error logging with a formatter that applies %q quoting or explicit byte filtering before writing to any sink
  • Restrict who can view raw log files and disable ANSI interpretation in log viewers and terminal multiplexers
  • Terminate TLS at a reverse proxy or load balancer that is not affected, until backend Go services can be patched

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

Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

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.