Summary
marimo's /terminal/ws WebSocket endpoint exposes a fully interactive PTY shell without enforcing authentication, allowing arbitrary command execution.
When reachable over the network, an unauthenticated attacker can connect to this endpoint and gain direct shell access to the host running marimo.
Affected context
This vulnerability appears in marimo deployments where:
- The application is exposed over a network interface (e.g., localhost port bind, container port, or reverse proxy).
- The /terminal/ws WebSocket endpoint is reachable from the attacker's network location.
- marimo is running in a mode and on a platform where the terminal feature (PTY) is enabled.
Under these conditions, the missing authentication check on /terminal/ws creates a direct path to an interactive shell.
Exploit preconditions
- Attack surface: Network-exposed WebSocket endpoint at
/terminal/ws. - Required access: None; exploitation is possible without prior authentication as long as the endpoint is reachable.
- Trigger point: Establishing a WebSocket connection to
/terminal/wswhen the terminal feature is enabled. - Why exploitation is possible: Unlike other endpoints (such as
/ws), the/terminal/wshandler omits a call to the authentication validation routine (validate_auth()), so any client can open a PTY-backed session and issue shell commands.
Why this happens
The root cause is a missing authentication enforcement for a sensitive functionality endpoint, aligning with CWE-306: Missing Authentication for Critical Function.
While other WebSocket routes explicitly invoke validate_auth() or equivalent checks, the /terminal/ws endpoint only evaluates runtime mode and platform support before accepting connections, leaving the terminal feature unguarded.
This inconsistent application of security checks creates an unintended privilege bypass, granting anonymous users access to a system shell.
Potential impact
- Unauthenticated execution of arbitrary system commands via a PTY shell.
- Complete compromise of the host running marimo, including data theft or modification.
- Lateral movement within the network reachable from the compromised host.
- Deployment of backdoors, malware, or persistence mechanisms on the system.
- Destruction or tampering with notebooks, configurations, or other local workloads.
General mitigation guidance
Effective mitigation generally involves enforcing consistent authentication and authorization for all sensitive endpoints and capabilities:
- Apply a uniform authentication layer to all WebSocket routes, especially those exposing shell or administrative functionality.
- Introduce centralized route registration patterns where security checks (like session or token validation) are applied by default, rather than on a per-endpoint basis.
- Restrict access to terminal-like functionality to explicitly authorized and minimally privileged users, enforcing role-based or capability-based controls.
- Reduce exposure by binding marimo to minimal network surfaces (e.g., loopback-only where feasible) and placing terminal features behind additional access controls such as VPNs or bastion hosts.
- Design with "secure by default" principles so new endpoints inherit strict authentication requirements unless deliberately relaxed for low-risk functionality.
How teams detect issues like this
Detection focuses on both code-level and deployment-level indicators:
- Static analysis and code review: Flag web or WebSocket endpoints that:
- Bypass shared authentication middleware or helpers.
- Implement custom connection handlers without calling standard auth routines.
- Expose PTY, shell, or administrative actions without explicit access checks.
- Configuration and policy checks: Enforce policy that all routes under certain paths (e.g.,
/terminal/*) require authentication and authorization, and monitor for exceptions. - Runtime monitoring: Log and inspect connections to administrative endpoints, detecting unexpected anonymous access patterns or unusual terminal activity.
- Automated tooling: Integrate automated review tools in CI that check for missing authentication attributes/annotations on handler functions and mismatched route security configurations.

