Skip to content

[Detail Bug] WebSocket connections remain authorized after authentication provider swap (provider-currency check missing) #36608

Done

Description

@detail-app

Detail Bug Report

https://app.detail.dev/org_3377c26d-da48-4ccd-b83a-22c542f4fe83/bugs/bug_bc4ea343-c973-4b4f-b1f5-947f7385f9ee

Introduced in #31423 by @mohityadav766 on Aug 13, 2026

Summary

  • Context: When an operator hot-swaps AUTHENTICATION_PROVIDER (e.g. moving the deployment from Google SSO to Azure SSO, a documented off-boarding mechanism), REST requests carrying session-bound tokens (the JWTs the server mints with a sessionId claim) are guarded by JwtFilter.validateSessionProviderIsCurrent, which immediately rejects any session issued by the now-deconfigured provider. The WebSocket entry points — the engine.io handshake filter and the periodic sweep that validates already-connected sockets — re-validate sessions but were never given the same check.
  • Bug: SocketAddressFilter.validateSessionStillActive (handshake) and WebSocketManager.isSessionActiveForUser (60s sweep) never check that UserSession.getProvider() is still among the configured providers, so sessions minted under a deconfigured provider remain fully usable on the socket path until natural expiry.
  • Actual vs. expected: REST requests fail immediately (session-bound tokens with "Session was issued by a provider that is no longer configured."; claim-less IdP tokens instead fail token validation under the new provider config) yet a WebSocket handshake is still accepted (cookie-only in the default insecure mode; claim-less-token + cookie in secure mode) and an already-connected socket survives every sweep iteration — while JwtFilter documents that provider-swapped sessions "must stop working immediately instead of living on until natural expiry".
  • Impact: A user off-boarded by moving IdPs keeps a live push channel for up to the full 7-day default session expiry, silently receiving every activity-stream broadcast (org-wide feed events), mentions, task notifications, and other WebSocket-pushed events, although their REST access has been cut and the stated intent is that their access ends immediately.

Code with Bug

openmetadata-service/src/main/java/org/openmetadata/service/socket/SocketAddressFilter.java — handshake session validation:

    Optional<UserSession> session = sessionService.getFreshSessionById(sessionId);
    if (session.isEmpty()
        || session.get().getStatus() != SessionStatus.ACTIVE
        || session.get().isExpired(System.currentTimeMillis())) {
      LOG.info(
          "Rejecting WebSocket handshake: session {} is not active",
          SessionService.truncateId(sessionId));
      response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Session is no longer active");
      return SessionValidationResult.rejected();
    }
    // <-- BUG 🔴 no check that session.get().getProvider() matches the currently configured provider

openmetadata-service/src/main/java/org/openmetadata/service/socket/WebSocketManager.java — periodic revalidation sweep:

  private boolean isSessionActiveForUser(
      SessionService sessionService, String sessionId, UUID expectedUserId) {
    return sessionService
        .getFreshSessionById(sessionId)
        .filter(
            session ->
                session.getStatus() == SessionStatus.ACTIVE
                    && !session.isExpired(System.currentTimeMillis())
                    && expectedUserId.toString().equals(session.getUserId()))
        .isPresent(); // <-- BUG 🔴 no provider-currency check; stale-provider sessions keep sockets alive
  }

Explanation

The REST/auth filter enforces a “provider-currency” policy: if a session was issued by an authentication provider that is no longer configured (after AUTHENTICATION_PROVIDER is swapped), the session must be rejected immediately.

WebSocket authentication/validation (both initial handshake and the 60s “disconnect inactive sessions” sweep) only checks session status/expiry and user binding, so a session issued under a deconfigured provider continues to authenticate and remains connected until it naturally expires.

Codebase Inconsistency

The REST path explicitly enforces the missing predicate:

  /**
   * Sessions record the provider that authenticated them. Swapping {@code AUTHENTICATION_PROVIDER}
   * decommissions that provider, so sessions minted under it must stop working immediately instead of
   * living on until natural expiry — otherwise off-boarding a user by moving IdPs leaves their old
   * token valid for up to a week.
   */
  private void validateSessionProviderIsCurrent(UserSession session) {
    ...
    if (!SessionProviders.isSameProvider(sessionProvider, providerType.value())) {
      throw AuthenticationException.getInvalidTokenException(
          "Session was issued by a provider that is no longer configured.");
    }
  }

Exploit Scenario

  1. A user signs in normally and gets an OM_SESSION cookie whose backing session is ACTIVE with provider = "google" (or another SSO provider), with a 7-day expiry.
  2. The user keeps an engine.io/WebSocket client connected (e.g. GET /api/v1/push with the OM_SESSION cookie). In the default insecure-socket mode, the cookie alone authenticates the handshake.
  3. The organization off-boards by swapping AUTHENTICATION_PROVIDER to a different IdP; REST requests now fail immediately.
  4. The WebSocket handshake and the periodic sweep accept/retain the old session because they do not check the session’s provider against current configuration.
  5. Until session expiry (up to 7 days by default), the client continues receiving activity-stream broadcasts and other WebSocket-pushed events.

Recommended Fix

Add the same provider-currency predicate used by REST (SessionProviders.isSameProvider(...) / existing SessionService.isFromAnotherProvider logic) to:

  • SocketAddressFilter.validateSessionStillActive to reject handshakes for sessions issued by deconfigured providers.
  • WebSocketManager.isSessionActiveForUser (or a SessionService helper it calls) so the sweep disconnects stale-provider sockets on the next tick.

History

This bug was introduced in commit 9397048 ("Fixes open-metadata/openmetadata-collate#5526: revoke sessions on user delete and provider swap, stop logging tokens at DEBUG (#31423)", 2026-08-13).

Tracing history:

  • SocketAddressFilter.validateSessionStillActive and WebSocketManager.isSessionActiveForUser were both originally shipped in 000fec7 ("Feature Session Management in Multiple Server Pods #21971: Session Management in Multiple Server Pods (Feature #21971: Session Management in Multiple Server Pods #26314)", 2026-06-03), which added socket-side session validation checking status, expiry and user-id binding. At that point there was no provider-currency semantics anywhere, so the absence of a provider check there was not yet a bug.
  • The provider-swap enforcement (SSO-27) — the requirement that sessions minted under a decommissioned AUTHENTICATION_PROVIDER "must stop working immediately instead of living on until natural expiry" — was introduced by 9397048. git show --stat confirms it touched JwtFilter.java (+54), SessionService.java (+61), SecurityUtil.java, UserRepository.java, the Basic/LDAP servlet handlers and their tests, but no socket files, leaving validateSessionStillActive and the 60s sweep without the check.
  • Later commits to the socket files (bff7e08 relay feature, ca9b8c0 hardening batch) did not add any provider-currency logic, so 9397048 remains the most recent commit that clearly contributed to the bug's existence: it created the REST-only asymmetry the report describes.

Activity

  1. Vamsi-klu commented on Nov 20, 2026

    @Vamsi-klu
    Contributor

    Triage on main@2cc8c552558: confirmed, and wider than the report. Under the default public client the UI opens the socket with the provider token and no OM_SESSION cookie, so the socket has no session and the sweep never re-checks it (WebSocketManager:132-134, :273); it outlives the swap indefinitely. Session-bound sockets are exposed through the cookie handshake (SocketAddressFilter.validateSessionStillActive) and the sweep (WebSocketManager.isSessionActiveForUser). A handshake that presents an OM token with a sessionId claim is already rejected, through JwtFilter.checkValidationsForToken -> validateSessionProviderIsCurrent.

    Planned fix:

    • A security reload that changes the provider closes every push-feed socket on that server; a basic/openmetadata rename closes nothing.
    • The handshake and the sweep apply the same check, through one predicate, SessionProviders.isFromAnotherProvider. JwtFilter also uses it.
    • Sockets are closed and sessions are not revoked, matching JwtFilter.
    • Regression IT in SessionMultiNodeIT.

    Separate follow-ups: sessionless sockets outliving token expiry and user deletion; same-type provider switches (tenant or issuer change); sockets rejecting REFRESHING sessions.

  2. added a commit that references this issue on Nov 24, 2026
    64141df
  3. added a commit that references this issue on Nov 24, 2026
    8677ece
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    • Status
      Done ✅

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions