Summary
Open WebUI terminal routing previously constructed upstream URLs using unencoded session identifiers and blindly forwarded user identity headers.
An attacker able to inject crafted query parameters could impersonate other users' identities in the terminal backend, potentially gaining unauthorized access to their sessions or actions.
Affected context
This vulnerability affects Open WebUI deployments that expose the terminal functionality through backend/open_webui/routers/terminals.py.
The risk is present when:
- Terminal WebSocket/HTTP traffic is proxied via
ws_terminalendpoints - Session identifiers are accepted from client-controlled sources
- Upstream URLs and query parameters are constructed directly from these values
- The backend trusts
X-User-Idor similar headers as proof of identity without cryptographic binding
Exploit preconditions
- Attack surface: Terminal WebSocket/HTTP endpoint used to connect to backend terminals.
- Required access: Ability to send crafted requests to the terminal route (e.g., authenticated user or any user permitted to open terminals).
- Trigger point: Construction of the
ws_terminalupstream URL and forwarding of identity-related query parameters/headers. - Why exploitation is possible: The implementation builds the upstream URL from an unencoded
session_idand appendsuser_idas a query parameter, allowing query injection that changes the effective user identity. Additionally, the HTTP proxy path forwardsX-User-Idas an integrity-unbound identity claim, so the terminal backend may treat attacker-controlled values as authoritative.
Why this happens
The root cause lies in improper authentication and identity binding between the WebUI and the terminal backend.
The router logic:
- Fails to treat
session_idanduser_idas untrusted inputs that must be strictly encoded and validated. - Constructs URLs by string concatenation, enabling query parameter injection.
- Uses
X-User-Idas a standalone indicator of identity without cryptographic protection, contextual verification, or binding to a session.
This behavior maps to CWE-287 (Improper Authentication) because the terminal backend effectively accepts identity assertions without robust verification, and to CWE-290 (Authentication Bypass by Spoofing) since an attacker can spoof another user's identity through manipulated parameters and headers.
Potential impact
- An attacker may impersonate another user when accessing terminal backends.
- Terminal sessions could be resolved under the wrong user identity, leading to unauthorized access to commands or data.
- Audit logs and accountability mechanisms can be corrupted, misattributing actions to the wrong user.
- Depending on deployment, attackers could gain access to sensitive system resources exposed via terminals under higher-privileged accounts.
General mitigation guidance
Effective mitigation focuses on hardening identity propagation and eliminating trust in client-controlled identity hints:
- Treat all query parameters and headers related to identity (
user_id,X-User-Id,session_id) as untrusted and validate them against server-side session state. - Use structured URL builders and parameter encoding instead of string concatenation to construct upstream URLs, preventing query injection.
- Bind user identity to a server-issued, integrity-protected token or session object that the terminal backend validates, rather than trusting raw IDs.
- Enforce strict authentication and authorization checks at the terminal backend layer, ensuring it verifies the caller's identity independently or via signed/securely propagated claims.
- Apply least-privilege principles to terminal access, limiting which users and roles can reach sensitive terminal backends.
How teams detect issues like this
Organizations can detect similar vulnerabilities through a combination of review and automated checks:
- Static analysis rules that flag direct string concatenation when building URLs with user-controlled data, especially when parameters resemble
user_id,session, or identity headers. - Code review checklists that require identity headers (e.g.,
X-User-Id) to be either cryptographically bound to a token or derived solely from trusted server-side state. - Security tests and fuzzing that attempt query parameter injection against terminal or proxy endpoints, observing whether user identities can be altered.
- Runtime monitoring and logging to detect anomalies such as identity changes within a single connection or inconsistent combinations of session identifiers and user IDs.
- Use of automated application security testing tools that specifically look for improper authentication and header-based identity spoofing patterns.

