Skip to content

Missing Origin validation on WebSocket upgrades allows Cross-Site WebSocket Hijacking

High
br41nslug published GHSA-mww8-4gwh-rjfw Aug 5, 2026

Package

npm directus (npm)

Affected versions

>= 10.10.5, < 12.1.0

Patched versions

12.1.0

Description

Missing Origin validation on WebSocket upgrades allows Cross-Site WebSocket Hijacking

Summary

The WebSocket upgrade handler accepted cross-origin upgrade requests that carried the directus_session_token session
cookie, without validating the Origin header of the handshake. A browser automatically attaches cookies to a WebSocket
handshake and, unlike the REST and GraphQL transports, the upgrade path is registered directly on the HTTP server and
therefore never passes through the CORS middleware. In affected deployments, a page on an attacker-controlled origin
could open a WebSocket to a Directus instance and have the connection authenticated as the visiting user.

Details

When a WebSocket upgrade request arrived with a session cookie present, the connection was authenticated from that
cookie and the socket was established with the corresponding user's accountability. No comparison was made against the
request host, PUBLIC_URL, or the CORS_ORIGIN allowlist before accepting the upgrade.

The cookie branch was evaluated ahead of the configured WebSocket authentication mode, so setting WEBSOCKETS_REST_AUTH
or WEBSOCKETS_GRAPHQL_AUTH to handshake or strict did not prevent a cookie-bearing handshake from being accepted.

Exploitation requires all of the following:

  • WebSockets are enabled (WEBSOCKETS_ENABLED=true). This is not the default.
  • The victim is signed in using session cookie authentication, which is the mode the Admin App uses.
  • The victim's browser attaches the session cookie to the attacker's cross-origin handshake. This happens when
    SESSION_COOKIE_SAME_SITE is set to none (a configuration used for cross-origin Admin App deployments), or when the
    attacker controls a site that is same-site with the API host, such as a sibling subdomain, in which case the default
    lax setting still sends the cookie.
  • The victim visits the attacker-controlled page while their session is valid.

Impact

An attacker who can get a signed-in user to load a page under their control can drive an authenticated WebSocket session
with that user's permissions. Over that connection they can read, create, update, and delete items, and open
subscriptions, on any collection the victim has access to. If the victim is an administrator, this extends to system
collections such as directus_users, directus_roles, and directus_permissions.

The attacker's page can read WebSocket responses directly, so this results in data disclosure as well as unauthorized
writes. The session token itself is HttpOnly and is not exposed to the attacker's script.

Workarounds

For deployments that cannot upgrade immediately:

  • Disable WebSockets (WEBSOCKETS_ENABLED=false) if they are not in use.
  • Avoid SESSION_COOKIE_SAME_SITE=none. Serving the Admin App and the API from the same site allows the default lax
    value, which prevents the cross-site case.
  • Enforce an Origin allowlist for the WebSocket paths at a reverse proxy in front of Directus.
  • Treat control of any subdomain sharing the API's registrable domain as equivalent to control of the session, and
    review subdomain ownership accordingly.

Credit

Reported by @tonghuaroot

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
Required
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N

CVE ID

No known CVE

Weaknesses

Cross-Site Request Forgery (CSRF)

The web application does not, or cannot, sufficiently verify whether a request was intentionally provided by the user who sent the request, which could have originated from an unauthorized actor. Learn more on MITRE.

Missing Origin Validation in WebSockets

The product uses a WebSocket, but it does not properly verify that the source of data or communication is valid. Learn more on MITRE.

Credits