Apr 11, 2026·7 min read·47 visits
A race condition in Juju's API server allows authenticated users to crash the server or replay authentication tokens due to thread-unsafe map operations.
Canonical Juju is affected by a medium-severity race condition vulnerability (CWE-362) within its API server. The vulnerability allows an authenticated attacker to trigger concurrent memory access violations in the Go runtime, resulting in an unrecoverable fatal panic and Denial of Service (DoS), or to bypass single-use token constraints via an authentication replay attack.
Canonical Juju is affected by a medium-severity race condition vulnerability tracked as CVE-2026-5774. The flaw resides within the API server component, specifically in the management of macaroon discharge tokens during the local login process. An authenticated attacker can exploit this vulnerability to induce a Denial of Service (DoS) state or bypass single-use token restrictions.
The root of the issue is categorized as CWE-362, concurrent execution using a shared resource with improper synchronization. The API server stores discharge tokens in a standard data structure that lacks inherent concurrency protections. When the server processes simultaneous HTTP requests, these requests execute in isolated goroutines but interact with the same underlying token storage mechanism.
This architectural choice creates an exposed attack surface on the /local-login/discharge and /local-login/form endpoints. A threat actor with valid credentials can dispatch carefully timed network requests to these endpoints, intentionally triggering the concurrency limits of the runtime environment. The resulting state corruption forces the API server process to terminate, disrupting management access to the Juju environment.
The vulnerability originates from the unsafe concurrent access patterns applied to a native Go map[string]string structure. In the Juju API server codebase, the localLoginHandlers struct utilizes a userTokens map to track active macaroon discharge tokens. The Go runtime mandates that map implementations are not thread-safe and strictly prohibits simultaneous memory access involving at least one write operation.
When the runtime detects a concurrent write, or a concurrent read and write against the same map instance, it triggers a fatal, non-recoverable panic. The Juju API server triggers this condition because the formHandler function continuously writes new authentication tokens to the userTokens map upon successful login events. Concurrently, the checkThirdPartyCaveat function reads tokens from the map for verification and subsequently issues a delete operation to ensure the token cannot be reused.
Because the Go HTTP server implementation handles each incoming request in a separate goroutine, high-frequency requests directly translate to concurrent execution threads. The absence of a mutual exclusion lock (mutex) around the userTokens map guarantees that these independent goroutines will eventually intersect during memory access.
Furthermore, the logic implemented in the checkThirdPartyCaveat function exhibits a Time-of-Check to Time-of-Use (TOCTOU) condition. The function first queries the map to verify token existence and then executes the deletion operation in a separate, non-atomic step. This execution gap allows two parallel verification threads to read the same token successfully before either thread removes the token from memory.
The codebase lacked synchronization primitives in the authentication handlers prior to the patch. The userTokens map was declared directly within the localLoginHandlers struct without an associated mutex. Token validation and deletion were performed sequentially in the caveat checker, exposing the TOCTOU window.
// Vulnerable implementation
type localLoginHandlers struct {
authCtxt *authContext
finder state.EntityFinder
userTokens map[string]string
}
// Non-atomic read and delete operation inside caveat checker
username, ok := h.userTokens[tokenString]
delete(h.userTokens, tokenString)The remediation introduced in commit 2bc884d34dce1a72f93e67202c1fd1385ad474b0 resolves the issue by adding a sync.Mutex field named tokenMutex to the struct. The developers refactored the map operations into dedicated, thread-safe methods. The getUserFromToken method now locks the mutex before accessing the map, reads the token, deletes it, and unlocks the mutex via a defer statement.
// Patched implementation
type localLoginHandlers struct {
authCtxt *authContext
finder state.EntityFinder
tokenMutex sync.Mutex
userTokens map[string]string
}
// Thread-safe, atomic read and delete operation
func (h *localLoginHandlers) getUserFromToken(token string) (string, bool) {
h.tokenMutex.Lock()
defer h.tokenMutex.Unlock()
username, ok := h.userTokens[token]
delete(h.userTokens, token)
return username, ok
}The following diagram illustrates the thread safety implementation introduced by the patch, ensuring that concurrent goroutines are sequentially gated.
An authenticated threat actor can exploit this vulnerability through the network by executing a race condition attack. The primary attack vector targets the availability of the API server. By generating a high volume of simultaneous HTTP requests to the /local-login/form and /local-login/discharge endpoints, the attacker forces the server to process multiple map operations simultaneously.
This deliberate flooding guarantees that at least two goroutines will attempt to modify or read the userTokens map at the exact same instruction cycle. The Go runtime detects this specific violation and intentionally crashes the application process with a fatal error: concurrent map writes message. The API server remains offline until restarted by the orchestration layer.
Alternatively, an attacker can exploit the TOCTOU behavior to replay authentication tokens. The attacker obtains a single valid macaroon discharge token via standard authentication procedures. The attacker then scripts two distinct HTTP clients to transmit the same token to the caveat checker endpoint at precisely the same time.
If the execution timing aligns properly within the vulnerable window, both goroutines evaluate the token presence check as true. The system authenticates both sessions before either goroutine advances to the deletion instruction. This technique bypasses the intended security design that explicitly mandates discharge tokens must be consumed exactly once.
The vulnerability presents two distinct impacts: total loss of availability for the API service and subversion of authentication mechanisms. The availability impact is classified as high because the resulting Go runtime panic is fatal. The process termination cannot be intercepted or handled by application-level error recovery routines, requiring a full process restart to restore service.
During the period the API server is offline, administrators lose management access to the Juju environment. Automated orchestration tasks, deployment processes, and health monitoring mechanisms dependent on the API fail to execute. This disruption scales in severity based on the operational reliance on the Juju controller.
The confidentiality and integrity impact resulting from the token replay vector is constrained by the attacker's existing privilege level. The attacker must already possess valid credentials to generate the initial discharge token. Replaying the token allows the generation of parallel authenticated sessions, but does not inherently escalate privileges beyond the permissions associated with the original compromised account.
The Common Vulnerability Scoring System (CVSS) v4.0 evaluation yields a score of 6.1 (Medium). The vector string CVSS:4.0/AV:N/AC:H/AT:P/PR:L/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N accurately reflects the network attack surface, the high complexity of timing the race condition, and the high impact on target availability.
Canonical resolved this vulnerability in three specific patch branches across the Juju ecosystem. Administrators operating Juju 4.0.x installations must upgrade to version 4.0.6 to secure the API server. Deployments running the Juju 3.6.x branch require an upgrade to version 3.6.21. Legacy installations on the Juju 2.9.x branch must update to version 2.9.57.
Organizations that cannot immediately apply the vendor patches should implement network-level rate limiting against the Juju controller interfaces. Throttling incoming connections to the /local-login/discharge and /local-login/form endpoints reduces the probability of concurrent execution overlap. While rate limiting does not eliminate the root cause, it significantly increases the attack complexity required to trigger the concurrency panic.
Security operations centers should deploy detection mechanisms targeting API server logs and network traffic patterns. Teams must monitor the application runtime logs for fatal error: concurrent map writes events, which serve as a definitive indicator of compromise or active exploitation attempts. High-frequency request clusters originating from a single authenticated source address should trigger automated defensive blocks.
CVSS:4.0/AV:N/AC:H/AT:P/PR:L/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N| Product | Affected Versions | Fixed Version |
|---|---|---|
Juju Canonical | 2.0.0 to < 2.9.57 | 2.9.57 |
Juju Canonical | 3.0.0 to < 3.6.21 | 3.6.21 |
Juju Canonical | 4.0.0 to < 4.0.6 | 4.0.6 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-362 |
| Attack Vector | Network |
| CVSS v4.0 Score | 6.1 (Medium) |
| Impact | Denial of Service (DoS) and Authentication Replay |
| Exploit Status | Proof of Concept |
| KEV Status | Not Listed |
Concurrent Execution using Shared Resource with Improper Synchronization
Gradle versions prior to 8.14.4 and 9.3.0 fail to classify certain fatal network transport exceptions, such as UnknownHostException and NoHttpResponseException, as critical failures during dependency resolution. When these exceptions occur and retry thresholds are exhausted, Gradle fails to disable the unreachable primary repository and instead falls through to subsequent repositories configured in the build script. An attacker capable of disrupting connectivity to an upstream repository can force the build tool to fetch malicious artifacts with matching coordinates from a downstream, untrusted repository.
NATS Server prior to versions 2.12.8 and 2.14.3 contains an incorrect authorization vulnerability (CWE-863) in its message tracing subsystem. When evaluating whether a connection is permitted to publish trace events to a destination subject specified in the Nats-Trace-Dest header, the server only checks standard client permissions and omits permission checks for leaf node connections. This allows a connected leaf node operator with restricted publishing privileges to emit internal trace events to unauthorized subjects and suppress standard message delivery using the Nats-Trace-Only header.
CVE-2026-63341 is a high-severity Denial of Service (DoS) vulnerability in the Aedes MQTT broker for Node.js affecting all versions prior to 1.1.1. The flaw stems from missing input validation on the hierarchical depth of incoming MQTT topic strings before they are passed to the underlying topic-matching engine, qlobber. Because qlobber enforces a hardcoded limit of 100 topic levels and throws a synchronous exception when this threshold is exceeded, an attacker can send a single MQTT packet containing 101 or more forward-slash-separated levels to trigger an uncaught exception that immediately terminates the Node.js broker process.
CVE-2026-61725 is a path traversal vulnerability (CWE-22) in the sevenz-rust2 Cargo package prior to version 0.21.1. The vulnerability occurs because the decompression utility fails to validate or sanitize archive entry filenames before joining them with the destination directory path via std::path::Path::join. An attacker who supplies a crafted 7z archive containing parent directory traversal sequences or absolute paths can write or overwrite arbitrary files on the host filesystem with the privileges of the extracting process.
CVE-2026-77309 (GHSA-jrjx-9jjw-747m) is a high-severity unauthenticated remote code execution vulnerability affecting NASA-AMMOS AIT-GUI versions 1.0.0 through 2.5.0. The flaw results from chaining an incomplete file cleanup error in the telemetry query endpoint (/tlm/query) with a directory traversal flaw in the script execution endpoint (/script/run). An attacker on an adjacent network can stage arbitrary Python statements into a static file on disk and execute that file under the privileges of the AIT-GUI web server process.
A vulnerability classified under CWE-116 (Improper Encoding or Escaping of Output) exists in memtomem-stm versions 0.1.0 through 0.1.33. The software acts as a Model Context Protocol (MCP) short-term memory proxy gateway for AI agent architectures. When surfacing retrieved memories and scratchpad items into downstream Large Language Model (LLM) context envelopes, the SurfacingFormatter component fails to properly sanitize untrusted memory attributes. An attacker with the ability to plant untrusted content into the agent's long-term or working memory store can inject arbitrary structural delimiters, close the <surfaced-memories> XML boundary prematurely, visually obscure instructions using Unicode bidirectional overrides, and execute stored prompt injection attacks against downstream LLM agents.