/

CVE-2026-39987

Severity:

CRITICAL RISK

(9.8)

Missing Authentication in marimo Reactive Python Notebook

CVE-2026-39987

Analyzed

Vulnerability type

Category:

Missing Authentication

CWE:

CWE-306

Impact:

Pre-Authentication Remote Code Execution

Severity:

CRITICAL RISK

(9.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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/ws when the terminal feature is enabled.
  • Why exploitation is possible: Unlike other endpoints (such as /ws), the /terminal/ws handler 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.

Sources

SourceLink
github.comgithub.com/marimo-team/marimo/commit/c24d4806398f30be6b12acd6c60d1d7c68cfd12a
github.comgithub.com/marimo-team/marimo/pull/9098
github.comgithub.com/marimo-team/marimo/security/advisories/GHSA-2679-6mx9-h9xc
cisa.govcisa.gov/known-exploited-vulnerabilities-catalog?field_cve=CVE-2026-39987
sysdig.comsysdig.com/blog/marimo-oss-python-notebook-rce-from-disclosure-to-exploitation-in-under-10-hours

Frequently asked

questions

It can be, if the marimo instance is bound to a network interface that is reachable from the internet or an untrusted network, and the /terminal/ws endpoint is not restricted by additional network controls such as firewalls or VPNs.

No. The vulnerability stems from the absence of an authentication check on /terminal/ws, so any unauthenticated client that can reach the endpoint may gain a PTY shell.

The most robust fix pattern is to ensure that all sensitive endpoints—especially those providing shell access, file operations, or administrative capabilities—enforce the same authentication and authorization mechanisms as the rest of the application, ideally through centralized middleware or framework-level guards rather than per-endpoint ad hoc checks.

Preventive strategies include adopting secure-by-default route registration (where new endpoints inherit strict auth requirements), using standardized middleware for authentication and authorization, enforcing code review checklists that explicitly ask about access control for new handlers, and running static analysis or policy tools that detect routes lacking required security annotations or checks.

Find out what's already
exploitable in your codebase.