Subscribe to the Non-Human & AI Identity Journal

WebSocket hijacking

WebSocket hijacking is unauthorised use of a WebSocket channel to send or receive messages as if the client were trusted. It usually exploits missing origin checks, weak session validation, or absent authentication, allowing an attacker to control functionality that was meant for a legitimate user or local process.

Expanded Definition

WebSocket hijacking is a channel takeover problem, not just a transport issue. In the NHI and application security context, it occurs when a browser or client establishes a persistent WebSocket connection and the server fails to verify that the peer is still authorised to send messages on that session. Unlike ordinary HTTP request abuse, the attack can persist for the life of the socket and can move real-time commands, events, or telemetry.

Definitions vary across vendors, but the security core is consistent: the server should authenticate the connection, validate origin or equivalent binding, and ensure the session cannot be reused by an untrusted context. Guidance from NIST SP 800-53 Rev 5 Security and Privacy Controls supports this by emphasising strong access enforcement and session protections for networked services. In agentic systems, the risk extends to tool-using services that open persistent links to internal APIs or brokers. The most common misapplication is treating a WebSocket as “already authenticated” after the initial handshake, which occurs when session checks are not repeated or bound to the actual origin and identity context.

Examples and Use Cases

Implementing WebSocket security rigorously often introduces connection-state complexity, requiring organisations to weigh real-time responsiveness against tighter session validation and re-authentication controls.

  • A collaboration app opens a socket after login, but the server does not verify the browser origin, allowing a malicious site to ride the user’s authenticated session.
  • An agentic workflow uses a WebSocket to stream tool commands; weak token binding lets an attacker inject instructions into the live channel.
  • A monitoring dashboard keeps a long-lived socket open to receive alerts, but session expiry is not enforced, so stale credentials remain usable.
  • A local desktop process connects to a backend over WebSocket, yet the service accepts any client that can reach the port, creating an unauthorised control path.
  • Teams reviewing enterprise identity exposure often discover adjacent weaknesses in broader NHI hygiene, as described in the Ultimate Guide to NHIs, especially when sockets and API keys are handled with the same loose trust assumptions.

For protocol-level expectations, the WebSocket specification in RFC 6455 explains the upgrade model that makes origin and session validation essential rather than optional.

Why It Matters in NHI Security

WebSocket hijacking is especially dangerous in NHI environments because the abused channel often carries actions performed by services, agents, or automation rather than a single human user. That makes the impact broader than account compromise alone: attackers can trigger deployments, alter messages, pull secrets, or manipulate event-driven controls without needing repeated authentication. NHI Mgmt Group research shows that only 5.7% of organisations have full visibility into their service accounts, which means many persistent connections are already operating inside weak oversight conditions. The same blind spot often affects sockets tied to API keys, service accounts, and embedded clients, where the identity of the caller is assumed instead of continuously checked.

This matters because real-time systems often fail quietly until an abnormal action is already in motion. The security implications also align with ENISA Threat Landscape reporting on application-layer abuse and session compromise, and with the broader NHI governance lessons in Ultimate Guide to NHIs. Organisations typically encounter the operational damage only after a live socket has been abused to issue unauthorised commands, at which point WebSocket hijacking becomes operationally unavoidable to address.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Non-Human Identity Top 10 and OWASP Agentic AI Top 10 address the attack and risk surface, while NIST CSF 2.0, NIST Zero Trust (SP 800-207) and NIST SP 800-63 set the governance and control requirements practitioners need to meet.

Framework Control / Reference Relevance
OWASP Non-Human Identity Top 10 NHI-03 Persistent channel abuse maps to authentication and session-binding weaknesses in NHI flows.
OWASP Agentic AI Top 10 AI-04 Agent tool channels are exposed when long-lived message streams lack trust boundaries.
NIST CSF 2.0 PR.AC-3 Remote access sessions must be authenticated and protected against unauthorised reuse.
NIST Zero Trust (SP 800-207) SC-23 Zero Trust requires untrusted network paths and session-specific verification for live channels.
NIST SP 800-63 Digital identity guidance informs stronger session assurance for authenticated clients.

Bind each WebSocket session to a verified identity and reject any connection that cannot prove origin and token continuity.