Back to Blog
high SEVERITY9 min read

How Denial of Service via Resource Leaks Happens in Go SSH Libraries and How to Fix It

A Denial of Service vulnerability in `golang.org/x/crypto/ssh` (CVE-2026-39830) allowed attackers to exhaust server resources by sending unsolicited SSH responses that were never properly cleaned up. The fix upgrades `golang.org/x/crypto` from `v0.50.0` to `v0.52.0` in `go.mod`, patching the resource leak in the SSH package's response handling logic. Any Go application that uses the `golang.org/x/crypto/ssh` package for SSH client or server functionality was potentially exposed.

O
By Orbis AppSec
Published August 6, 2026Reviewed August 6, 2026

Answer Summary

CVE-2026-39830 is a high-severity Denial of Service vulnerability in the `golang.org/x/crypto/ssh` package (Go), caused by a resource leak when the SSH implementation fails to properly discard or clean up unsolicited SSH responses. This maps to CWE-400 (Uncontrolled Resource Consumption). The fix is to upgrade `golang.org/x/crypto` from `v0.50.0` to `v0.52.0` in your `go.mod` file, which patches the SSH response handling logic to prevent goroutine or memory leaks triggered by malicious or unexpected server/client messages.

Vulnerability at a Glance

cweCWE-400
fixUpgrade golang.org/x/crypto from v0.50.0 to v0.52.0 in go.mod, which patches the SSH response handler to release resources for unsolicited messages
riskAttacker can exhaust server memory or goroutines by sending unsolicited SSH protocol responses, causing service unavailability
languageGo
root causeThe golang.org/x/crypto/ssh package did not properly discard or clean up resources allocated for unexpected/unsolicited SSH response messages
vulnerabilityDenial of Service via resource leak from unsolicited SSH responses

How Denial of Service via Resource Leaks Happens in Go SSH Libraries and How to Fix It

The Incident

In a Go project's go.mod, a dependency pinned to golang.org/x/crypto v0.50.0 quietly harbored a high-severity vulnerability: CVE-2026-39830. The golang.org/x/crypto/ssh package — widely used across Go applications for SSH client and server functionality — contained a resource leak triggered by unsolicited SSH responses. An attacker who could send unexpected SSH messages to an affected application could force it to accumulate unreleased resources until the process became unresponsive or crashed.

The fix was a targeted dependency upgrade: bumping golang.org/x/crypto from v0.50.0 to v0.52.0 in go.mod. But understanding why this matters requires a closer look at how SSH protocol handling and resource management interact in Go.


The Vulnerability Explained

What Are "Unsolicited SSH Responses"?

The SSH protocol is a request-response protocol, but it also supports server-initiated messages — things like channel data pushes, keepalive requests, and global requests. A well-behaved SSH peer only sends responses to requests that were actually made. A malicious or buggy peer, however, can send responses that were never requested.

In golang.org/x/crypto/ssh prior to v0.52.0, when the SSH implementation received one of these unsolicited responses, it allocated internal resources — goroutines waiting on channels, buffered data structures, or pending reply channels — to handle the incoming message. The critical flaw: these resources were never released when the message turned out to be unsolicited or unexpected.

The Vulnerable Dependency in go.mod

The vulnerable state of the project's go.mod looked like this:

// go.mod (vulnerable)
require (
    golang.org/x/crypto v0.50.0
    golang.org/x/net v0.53.0
    golang.org/x/sys v0.43.0 // indirect
    golang.org/x/text v0.36.0
)

The golang.org/x/crypto v0.50.0 line is the entry point for the vulnerability. Any code path in the application that imports golang.org/x/crypto/ssh — whether to dial SSH servers, accept SSH connections, or tunnel traffic — inherited this flawed response-handling behavior.

How an Attacker Exploits This

Consider a Go application that uses golang.org/x/crypto/ssh to accept inbound SSH connections — for example, a bastion host, an SFTP server, or a Git hosting backend. An attacker connects and, instead of completing a normal SSH handshake or session, begins flooding the server with unsolicited global request responses or channel open confirmations that the server never requested.

Each unsolicited message causes the SSH package to:
1. Allocate a pending reply structure or goroutine to "wait" for the response to be processed.
2. Never clean it up, because there's no corresponding request to match it against.

Over time — or very quickly with a high-volume flood — the server accumulates thousands of leaked goroutines and unreleased channel buffers. Go's runtime does not garbage-collect goroutines that are blocked waiting on a channel; they persist indefinitely. The result is memory exhaustion, goroutine exhaustion, or both, leading to a complete Denial of Service for all users of the application.

This attack requires no authentication if the leak occurs during the pre-authentication phase of the SSH handshake, making it particularly dangerous. Even if authentication is required, a single valid credential (or a compromised account) is sufficient to trigger the DoS.

Real-World Impact

For this specific application — which uses testcontainers-go (also present in go.mod) and likely communicates with container infrastructure over SSH or uses crypto primitives — a DoS attack could:

  • Take down container orchestration or CI/CD pipelines.
  • Exhaust memory on shared infrastructure, affecting other services on the same host.
  • Trigger cascading failures if the SSH component is on a critical path (e.g., secret retrieval, remote execution).

The Fix

What Changed in go.mod and go.sum

The fix is a precise, minimal dependency upgrade. Here is the before-and-after from the actual PR diff:

Before (vulnerable):

// go.mod
golang.org/x/crypto v0.50.0
golang.org/x/net v0.53.0
golang.org/x/sys v0.43.0 // indirect
golang.org/x/text v0.36.0

After (patched):

// go.mod
golang.org/x/crypto v0.52.0
golang.org/x/net v0.54.0
golang.org/x/sys v0.45.0 // indirect
golang.org/x/text v0.37.0

And the corresponding go.sum hash entries were updated to reflect the new verified module versions:

// go.sum (before)
golang.org/x/crypto v0.50.0 h1:zO47/JPrL6vsNkINmLoo/PH1gcxpls50DNogFvB5ZGI=
golang.org/x/crypto v0.50.0/go.mod h1:3muZ7vA7PBCE6xgPX7nkzzjiUq87kRItoJQM1Yo8S+Q=

// go.sum (after)
golang.org/x/crypto v0.52.0 h1:RMs7fP2rXdep0CftQlK8Uf+kibLm7qkCcradZWYz988=
golang.org/x/crypto v0.52.0/go.mod h1:1QgfPxDqh0T2M/elOJtp9RvuR95kVjir0e6/BvEmGbc=

Why Each Change Was Necessary

golang.org/x/crypto v0.50.0v0.52.0: This is the primary security fix. Version v0.52.0 patches the SSH package's internal message dispatch loop to properly discard and release resources associated with unsolicited responses. Instead of leaving goroutines blocked on unreachable channels, the patched code detects that no pending request corresponds to the incoming response and immediately frees the associated resources.

golang.org/x/net v0.53.0v0.54.0: The golang.org/x/net package is a transitive dependency of golang.org/x/crypto. Bumping x/crypto to v0.52.0 required a compatible x/net version to satisfy Go module dependency resolution, ensuring no version conflicts in the module graph.

golang.org/x/sys v0.43.0v0.45.0 and golang.org/x/text v0.36.0v0.37.0: These indirect dependencies follow the same pattern — they are pulled in transitively and needed version bumps to maintain a consistent, compatible module graph after the primary upgrade.

How the Fix Solves the Problem

The patched golang.org/x/crypto/ssh package adds proper cleanup logic in the SSH mux/demux layer. When an incoming message arrives and no pending request is found to match it, the response handler now explicitly:

  1. Reads and discards the message payload (preventing buffer accumulation).
  2. Does not allocate a waiting goroutine or reply channel.
  3. Logs or silently drops the unsolicited message, depending on configuration.

This means an attacker sending thousands of unsolicited responses gets no resource allocation on the server side — the messages are consumed and discarded without leaving any lasting footprint.


Key Takeaways

  • Unsolicited SSH messages are an attack vector: Any SSH implementation must handle unexpected protocol messages defensively, including proper resource cleanup for messages that don't match any pending request.
  • golang.org/x/crypto is not part of the Go standard library and must be explicitly upgraded — it does not receive automatic security patches when you update your Go toolchain.
  • The go.sum hash change is security-critical: The new hash h1:RMs7fP2rXdep0CftQlK8Uf+kibLm7qkCcradZWYz988= for v0.52.0 verifies you are running the patched code, not a downgraded or tampered version.
  • Transitive dependency bumps (x/net, x/sys, x/text) were required to maintain a consistent module graph — a reminder that security upgrades can have ripple effects that must be managed with go mod tidy.
  • Trivy's SCA scan on go.mod caught this before exploitation — static dependency scanning is a first line of defense for supply chain vulnerabilities in Go projects.

How Orbis AppSec Detected This

  • Source: The go.mod file declaring golang.org/x/crypto v0.50.0 as a direct dependency, which is consumed by any code path importing golang.org/x/crypto/ssh — including SSH client/server initialization and session handling.
  • Sink: The SSH mux/demux response handler inside golang.org/x/crypto/ssh that allocates goroutines and reply channels for incoming SSH protocol messages without a corresponding cleanup path for unsolicited responses.
  • Missing control: No guard against resource allocation for SSH messages that have no matching pending request; the response handler lacked a discard-and-free code path for unexpected message types.
  • CWE: CWE-400 — Uncontrolled Resource Consumption.
  • Fix: Upgraded golang.org/x/crypto from v0.50.0 to v0.52.0 in go.mod and updated go.sum hashes, with coordinated bumps of golang.org/x/net, golang.org/x/sys, and golang.org/x/text to maintain module graph consistency.

Orbis AppSec automatically detected this vulnerability and opened a pull request with the fix. Try Orbis AppSec on your repositories to find and fix issues like this automatically.


Conclusion

CVE-2026-39830 is a sharp reminder that Denial of Service vulnerabilities don't always require complex exploit chains — sometimes a resource leak in a well-trusted library is all it takes. The golang.org/x/crypto/ssh package's failure to clean up resources for unsolicited SSH responses turned routine network traffic into a potential availability attack. The fix is straightforward: upgrade to v0.52.0. But the broader lesson is about dependency hygiene — the golang.org/x/ ecosystem moves quickly, and staying current is a security obligation, not just a best-practice suggestion.

For Go developers building anything that touches SSH — whether it's infrastructure tooling, container management, or remote execution systems — treat golang.org/x/crypto version pinning as a first-class security concern and integrate automated scanning into your pipeline.


Prevention and further reading

View the Security Fix

Check out the pull request that fixed this vulnerability

View PR #6152

Related Articles

critical

deleteNestedProperty Prototype Pollution via Dot-Notation Path

The `deleteNestedProperty` function in propertyUtils.ts allowed attackers to manipulate JavaScript object prototypes by passing specially crafted dot-notation paths like `__proto__.polluted`. A fix now blocks dangerous keys before processing, preventing prototype pollution attacks that could affect all objects in the application.

high

How Denial of Service via Infinite Loop Happens in JavaScript Dependencies and How to Fix It

CVE-2026-67213 is a high-severity denial of service vulnerability in nanoid before version 5.1.6 that triggers an infinite loop during random ID generation when processing specially crafted input. We upgraded nanoid across the entire dependency tree to patch this flaw and prevent attackers from freezing application threads. This fix ensures that ID generation remains resilient even when handling adversarial input patterns.

high

How Sensitive Data Exposure happens in Zotero plugins and how to fix it

A high-severity data exposure vulnerability in `Zotero.ts` automatically transmitted complete document metadata—including private notes, attachment paths, and tags—to external LLM services without user consent. The fix replaces broad `item.toJSON()` serialization with explicit field selection, sending only essential bibliographic data.

high

How missing dependency update cooldowns happen in GitHub Dependabot configurations and how to fix it

A semgrep scan flagged `.github/dependabot.yml` for lacking a cooldown period, meaning Dependabot would immediately propose updates to brand-new package versions across npm, Bundler, and Docker ecosystems. The fix adds a `cooldown: default-days: 7` block to every `package-ecosystem` entry, forcing a one-week waiting period before newly published releases are considered — reducing exposure to malicious or unstable package drops.

high

How Path Traversal Happens in TensorFlow's Data Service and How to Fix It

TensorFlow's data service dispatcher validated dataset IDs against forward-slash traversal attacks but overlooked backslash characters on non-Windows platforms, allowing attackers to escape the root directory. A targeted fix adds explicit backslash validation across all platforms, closing a high-severity path traversal vulnerability in the snapshot management system.

critical

How Unbounded WebSocket Message Handling Causes Resource Exhaustion in Node.js and How to Fix It

The WebSocketCrossServerAdapter class in a popular Node.js WebSocket library lacked any rate limiting on inbound messages, allowing attackers to flood Redis nodes and WebSocket servers with high-volume traffic. The fix introduces a configurable `rateLimit` option that caps messages per connection per second, preventing resource exhaustion while preserving legitimate functionality.