Mar 24, 2026·6 min read·179 visits
A session hijacking vulnerability in NATS-Server allows an unauthenticated attacker to intercept private MQTT messages by exploiting Client ID hash collisions and null-byte truncation.
NATS-Server versions prior to 2.11.15 and 2.12.5 contain multiple vulnerabilities within the MQTT session management and packet parsing logic. These flaws, notably a Client ID hash collision weakness and null-byte truncation, allow unauthenticated remote attackers to hijack active MQTT sessions and intercept private message streams.
NATS-Server implements an MQTT interface backed by its JetStream persistence engine. The system relies on Client IDs to map incoming connections to existing message streams and subscriptions. An unauthenticated remote attacker can manipulate these Client IDs to bypass authentication mechanisms and hijack active sessions.
The vulnerability comprises several distinct software defects affecting how the server processes MQTT identifiers. The primary defect involves a hash collision weakness within the session persistence layer. Secondary defects include improper input validation concerning null-byte truncation and protocol desynchronization in fixed-size control packets.
Successful exploitation allows the attacker to assume the identity of a legitimate client. The server subsequently routes the victim's private message stream to the attacker. This exposes sensitive data and potentially disrupts the legitimate client's connection.
The JetStream backend uses a custom hashing function to optimize lookups for persisted MQTT sessions. When a client reconnects with the cleanSession=false flag, the server calculates the hash of the provided Client ID to retrieve the corresponding session state. The server failed to verify that the string identifier of the retrieved session matched the string identifier of the requesting client.
This logical omission creates a direct session hijacking vector. If two distinct Client IDs produce identical hash values, the server treats them as the same entity. The custom hashing algorithm used by NATS-Server exhibits sufficient collision probability to make this practically exploitable by brute-forcing local hashes until a match is found for a target ID.
Beyond the hashing flaw, the server processes MQTT string identifiers without sanitizing null bytes. If internal string handling logic truncates the input at the first null byte, an attacker can append arbitrary characters to a legitimate Client ID. This bypasses length restrictions while still mapping to the victim's internal session representation.
Furthermore, clustered deployments suffer from state desynchronization due to improper struct comparisons. The server relies on reflect.DeepEqual to enforce idempotency during stream creation. The StreamSource struct contains an internal iname field mutated exclusively by the server, causing mathematically identical user requests to be rejected as mismatched configurations.
The primary vulnerability resides in the session retrieval logic where the server implicitly trusts the hash index. The vulnerable implementation retrieves the session object based solely on the integer hash value. The code returns the session immediately without verifying the underlying string identifiers.
The patch introduced in commit 43e13a40a67a43880d14293791799fc5b0465bb5 corrects this by adding explicit string comparison. After fetching the session via the hash index, the server now performs a strict equality check. If the identifiers differ, the server rejects the connection and returns an authentication failure.
// Conceptual logic based on NATS-Server MQTT implementation
// Vulnerable Logic
sessionHash := getHash(requestedClientID)
if session, exists := server.sessions[sessionHash]; exists {
// Implicit trust of the hash index
return session
}
// Patched Logic
sessionHash := getHash(requestedClientID)
if session, exists := server.sessions[sessionHash]; exists {
// Explicit identifier verification added
if session.ClientID != requestedClientID {
return nil, ErrSessionMismatch
}
return session
}A parallel patch addressed the null-byte truncation vulnerability in commit adfb16280e2a842ffe102b398170552b9112b919. The developers added explicit boundary checks across all MQTT string parsing functions. The parser now iterates through the byte array and raises a protocol error if a \0 character is encountered within the Client ID, username, or topic strings.
The clustered stream state desynchronization also required a structural fix. The patch in commit ad80e455d8624ba01cfa69a05c7090e448ccfab3 modified the clustering layer. Before evaluating reflect.DeepEqual, the server now explicitly synchronizes the iname field from the existing state to the proposed state. This guarantees that internal metadata does not cause false negatives during configuration equivalence checks.
An attacker requires network access to the target NATS-Server MQTT interface, which defaults to port 1883. The attacker also needs prior knowledge of a victim's Client ID. Once the target ID is known, the attacker computes the NATS-specific hash for that ID offline.
The attacker generates millions of random Client IDs locally, hashing each until a collision with the target hash is found. The NATS test suite demonstrates this exact scenario using known colliding IDs, such as cid-03579431 and cid-09191235. The attacker connects to the server using the collided ID and sets the MQTT cleanSession flag to false.
The server processes the connection request, hashes the attacker's ID, and inadvertently retrieves the victim's persistent session. The server binds the attacker's network connection to the victim's session state. Any pending messages or future messages published to the victim's subscribed topics are actively routed to the attacker.
The primary impact of this vulnerability is a severe breach of message confidentiality. An attacker successfully exploiting the hash collision or null-byte truncation vectors gains full read access to the victim's subscribed message streams. Depending on the deployment context, this exposes sensitive telemetry, command-and-control directives, or private user data.
Integrity is indirectly affected if the attacker leverages the hijacked session to publish messages under the victim's identity. While the official CVSS vector scores integrity as None, application-level spoofing remains a practical consequence in systems lacking external message-level cryptographic signatures. The server explicitly trusts the connection as belonging to the victim.
Availability is compromised due to session displacement mechanics. MQTT protocol rules dictate that a new connection using an existing Client ID session forces the server to disconnect the older connection. The legitimate client experiences a persistent denial-of-service condition and is repeatedly disconnected as long as the attacker maintains the colliding session.
System administrators must upgrade NATS-Server deployments to versions 2.11.15 or 2.12.5. These releases contain the necessary string verification checks and strict input parsing logic required to prevent identifier manipulation. Environments running the 2.12 release candidate series must upgrade to 2.12.6-RC.1.
If immediate patching is unfeasible, administrators should restrict network access to the MQTT listener port. Implementing strict firewall rules or utilizing mutual TLS ensures that only trusted clients can initiate connections. This mitigates the risk of external exploitation by unauthorized external actors.
Organizations should implement strict Client ID naming policies and leverage NATS Authorization Callouts. By validating the Client ID against an external identity provider during the connection phase, administrators enforce a strict one-to-one mapping between authenticated users and their authorized MQTT session identifiers.
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:L| Product | Affected Versions | Fixed Version |
|---|---|---|
nats-server nats-io | < 2.11.15 | 2.11.15 |
nats-server nats-io | 2.12.0-RC.1 to < 2.12.5 | 2.12.5 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-287, CWE-488 |
| Attack Vector | Network |
| CVSS Score | 6.5 |
| Exploit Status | Proof-of-Concept |
| KEV Status | Not Listed |
| Impact | Session Hijacking, Message Interception |
The product does not adequately verify the identity of the user attempting to access a specific session or resource.
CVE-2026-16454 is an object-level authorization bypass vulnerability (CWE-284, CWE-862) in Eclipse hawkBit versions 1.0.3 and prior. The flaw exists within the Direct Device Integration (DDI) REST controller (hawkbit-ddi-resource), where endpoints responsible for enumerating software module metadata and serving firmware binaries fail to verify whether the requested software module is assigned to the authenticated device. Consequently, any device with valid credentials (such as a TargetToken or GatewayToken) can enumerate software module identifiers and download arbitrary firmware artifacts across the entire tenant namespace.
CVE-2026-62284 (GHSA-5w5g-j6hw-6p8f) is a code injection and server-side request forgery vulnerability in the console-proxy component of the OSAC Operator. The RemoteConfigResolver parses Kubernetes Secrets containing kubeconfig files via clientcmd.RESTConfigFromKubeConfig without sanitizing execution-related fields. An attacker with RBAC permissions to create or modify labeled Secrets in monitored namespaces can supply a malicious exec credential plugin, resulting in arbitrary command execution within the console-proxy pod.
CVE-2026-62361 (GHSA-xgjr-7j9q-2h4r) is an authenticated SQL injection and authorization bypass vulnerability in listmonk, an open-source, self-hosted newsletter and mailing list manager written in Go. In versions prior to 6.2.0, the subscriber export endpoint (GET /api/subscribers/export) directly interpolates user-supplied SQL filter expressions into a PostgreSQL query without invoking the table allowlist validation function (validateQueryTables). Consequently, authenticated users possessing the subscribers:sql_query and subscribers:get_all permissions can bypass relational access controls, execute arbitrary subqueries against restricted tables such as users and settings, and modify database state via writable Common Table Expressions (CTEs).
CVE-2026-28385 (GHSA-3gq2-x4qg-p4g6) is a Server-Side Request Forgery (SSRF) vulnerability in Canonical LXD versions 4.12 through 6.9. An authenticated user possessing the can_create_images entitlement can force the LXD daemon to execute arbitrary outbound HTTP and HTTPS requests via the /1.0/images API endpoint. Due to the absence of egress destination validation, an attacker can probe host loopback services, RFC 1918 private network segments, and cloud Instance Metadata Services (IMDS) from the network position of the privileged LXD daemon.
Canonical LXD and LXC Incus contain an arbitrary file write vulnerability (CWE-73 / CWE-59) in the `/1.0/instances/<name>/exec` REST API endpoint. When an instance is unpacked from an image archive, top-level symbolic links are extracted directly onto the host filesystem within the instance storage directory. If a crafted image includes a symbolic link named `exec-output` pointing to an arbitrary host path, invoking the execution endpoint with `record-output: true` causes the privileged host daemon to follow the symlink and write command output files directly to the target host directory. An authenticated attacker with permissions to import images and execute commands can exploit this flaw to write controlled content to sensitive host directories such as `/etc/cron.d`, resulting in arbitrary code execution on the host as `root`.
CVE-2026-48749 (tracked as GHSA-vghh-5rfx-xhq8 for LXD and GHSA-2q3f-q5pq-g8wv for Incus) is a critical container escape vulnerability in the Canonical LXD and Linux Containers Incus system container managers. By importing a specially crafted container image archive containing duplicate tar member headers, an authenticated attacker can replace the instance rootfs directory with a symbolic link pointing to the underlying host root filesystem. When performing file operations on a stopped container, the privileged forkfile helper binary resolves the symbolic link without confinement and chroots directly into the host filesystem, granting arbitrary root-level file read and write access.