-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The runtime flips on an environment variable.\n\nNocoBase's `ScriptInstruction.ts` exposes a single `workerScript` getter that the Worker constructor consumes:\n\n```typescript\nstatic get workerScript() {\n const hasModules = process.env.WORKFLOW_SCRIPT_MODULES?.split(',').filter(Boolean).length > 0;\n return path.join(__dirname, hasModules ? 'Vm.js' : 'IsolatedVm.js');\n}\n```\n\n`IsolatedVm.js` runs the user-supplied script in an `isolated-vm` V8 isolate: a separate V8 instance with no shared object graph, no shared prototype chain back to the host, no `require`. The post-condition the file's comment claims (`no require, no Node.js APIs`) is mechanically true; the script the operator's user supplies has no primitive that reaches the host process.\n\n`Vm.js` runs the user-supplied script in `new (require('node:vm').Script)(code).runInNewContext(context)`. The contract is different. `node:vm` is a same-process construct that swaps out the global object for a fresh one but reuses the host realm's prototype graph. Any object the host hands into the context carries its prototype chain with it. The Node.js documentation page for the `vm` module, paragraph one, says, verbatim: \"The `node:vm` module is not a security mechanism. Do not use it to run untrusted code.\"\n\n`Vm.js` is the runtime selected whenever `WORKFLOW_SCRIPT_MODULES` is set to a non-empty list of allowed module names. Operators set the variable when their workflow scripts need `require('crypto')` or `require('path')` or anything else. The configuration knob is documented in NocoBase's plugin README; it is the operator-facing way to make the Script node useful for any work that needs library calls. Setting it flips the runtime to the one the codebase's own comment marks `unsafe; not a security boundary`.\n\n## The escape is two short lines.\n\nThe PoC's payload, in full:\n\n```javascript\nconst escape = console._stdout.constructor.constructor(\"return process\")();\nconst child_process = escape.mainModule.require(\"child_process\");\nchild_process.execSync(``, {encoding: \"utf8\"});\n```\n\n`console._stdout`, in any Node.js worker context, is a `WritableWorkerStdio` stream (the worker_threads stdout implementation). `Object.getPrototypeOf(console._stdout).constructor` is `Writable`. `Writable.constructor` is the host realm's `Function`, because the stream's prototype chain runs `WritableWorkerStdio → Writable → Stream → EventEmitter → Object`, and every link in that chain is a constructor whose own `.constructor` is the host's `Function`. `Function(\"return process\")()` evaluates the string in the host realm and returns the host `process`. `process.mainModule.require` is the unconstrained `require`, not the plugin's allowlisted wrapper. `child_process.execSync` is RCE.\n\nThe chain is what Node's own documentation warns about. Any object handed across the `node:vm` boundary with its prototype chain intact is a Function-constructor reach.\n\nThe PoC is delivered to `/api/flow_nodes:test`, the workflow-node test endpoint:\n\n```python\nexploit_data = {\n \"type\": \"script\",\n \"config\": {\n \"script\": js_payload\n },\n \"upstreamResult\": {}\n}\nresp = session.post(f\"{base_url}/api/flow_nodes:test\", json=exploit_data, ...)\n```\n\n`flow_nodes:test` runs `ScriptInstruction.test(config)` directly. The script executes before any workflow is saved. The ACL snippet that gates the endpoint is `pm.workflow.workflows`: any role with workflow-management permission can call it. The CVE vector is `AV:N/AC:L/PR:L`, low privileges required.\n\n## The pre-patch sandbox tried to harden console by enumeration.\n\nNocoBase's open-sourced `Vm.js`, the version that shipped with v2.0.26 and earlier, was already doing console-hardening. The author had seen the threat. The implementation:\n\n```javascript\nfunction createSafeConsole(originalConsole) {\n const safe = Object.create(null);\n Object.defineProperty(safe, 'constructor', { value: null, /* ... */ });\n\n const allKeys = Reflect.ownKeys(originalConsole);\n for (const key of allKeys) {\n const descriptor = Object.getOwnPropertyDescriptor(originalConsole, key);\n if (!descriptor) continue;\n\n const wrap = (fn) => {\n const bound = fn.bind(originalConsole);\n Object.defineProperty(bound, 'constructor', { value: null, /* ... */ });\n return bound;\n };\n\n if (typeof descriptor.value === 'function') {\n descriptor.value = wrap(descriptor.value);\n }\n if (typeof descriptor.get === 'function') {\n descriptor.get = wrap(descriptor.get);\n }\n if (typeof descriptor.set === 'function') {\n descriptor.set = wrap(descriptor.set);\n }\n descriptor.configurable = false;\n Object.defineProperty(safe, key, descriptor);\n }\n\n return Object.freeze(safe);\n}\n```\n\nRead it carefully. `Reflect.ownKeys(originalConsole)` returns every own key on the host `console`. The author iterates each key, fetches its descriptor, wraps the function values, and installs the descriptor on `safe`. Function values are wrapped to null out their `.constructor`. Accessor functions are wrapped.\n\nObject values are not wrapped. The `if (typeof descriptor.value === 'function')` check is the gate, and `console._stdout` does not pass it. The descriptor flows through to `Object.defineProperty(safe, key, descriptor)` with `descriptor.value` still pointing at the original host `WritableWorkerStdio` instance.\n\nThe `createSafeConsole` function exists. It runs. It nulls every function's `constructor`. It freezes the result. It is hardening that was specifically written to prevent prototype-chain escape, and it does not prevent the escape, because the threat model the author held in their head was \"every property of console is a function.\" It is not. `_stdout`, `_stderr`, and `_times` are not.\n\n## The patch is one mental-model change.\n\nPull request #8967 (merged March 26, 2026, shipped in v2.0.28 on March 27) was authored by `mytharcher`, the same NocoBase team member who shipped the pre-patch version. The diff replaces `Reflect.ownKeys(originalConsole)` with an `allowedMethods` constant:\n\n```diff\n- const allKeys = Reflect.ownKeys(originalConsole);\n- for (const key of allKeys) {\n- const descriptor = Object.getOwnPropertyDescriptor(originalConsole, key);\n- // wrap if descriptor.value is a function\n- Object.defineProperty(safe, key, descriptor);\n- }\n+ const allowedMethods = [\n+ 'log', 'info', 'warn', 'error', 'debug', 'trace',\n+ 'dir', 'dirxml', 'table', 'time', 'timeEnd', 'timeLog',\n+ 'count', 'countReset', 'group', 'groupCollapsed', 'groupEnd',\n+ 'clear', 'assert',\n+ ];\n+ for (const key of allowedMethods) {\n+ if (typeof originalConsole[key] === 'function') {\n+ const bound = originalConsole[key].bind(originalConsole);\n+ hardenFunction(bound);\n+ Object.defineProperty(safe, key, { value: bound, /* ... */ });\n+ }\n+ }\n```\n\nThe patch adds one comment, and the comment is the bug class named in one line:\n\n```javascript\n// Internal properties like _stdout, _stderr, _times are NOT exposed to prevent\n// prototype chain traversal attacks (CVE: sandbox escape via WritableWorkerStdio).\n```\n\nThe pre-patch shape was \"wrap everything; the unsafe shape is a raw host function.\" The post-patch shape is \"allow nineteen logger methods; everything else is denied.\" Same author, twenty-eight days apart, on a file the author maintains. The fix is not a code change. The fix is a mental-model change: from \"console's keys are functions\" to \"console has internal Writable streams whose constructor chain is the host Function.\"\n\nThe CHANGELOG entry for v2.0.28 lists this as `Fix security issues (#8967)`. No CVE was assigned at that time. No vendor advisory was filed. The fix shipped silently in a Friday release with two other bug fixes.\n\n## The deeper fix lasted three days.\n\nTwenty-three days after #8967, the same author shipped a second, deeper patch. Pull request #9084 (merged April 18, 2026, shipped in v2.0.40 on April 20) added more than six hundred lines to `Vm.js` and its security test suite. The commit message names the next class of bypass:\n\n> Extend the sandbox hardening to also sanitize objects returned by wrapped\n> module functions (including Promise resolutions), so that prototype-chain\n> traversal via return values (e.g. crypto.createHash().update.constructor)\n> cannot reach the host Function constructor.\n\nThe fix added a `sanitizeReturnValue()` helper that wrapped every value crossing back from a wrapped module function into the sandbox, a `resolveProperty()` helper to evaluate accessor descriptors safely, a `sanitizeError()` helper that re-wrapped errors thrown from host functions, and a `MAX_PROTO_DEPTH=3` prototype walk that re-wrapped methods found anywhere on an object's prototype chain. The commit is co-authored by Claude Sonnet 4.6.\n\nIt lasted three days. Pull request #9176 (merged April 21, 2026, shipped in v2.0.41 on April 22) is titled `Revert \"fix(plugin-workflow-javascript): fix security issue (#9084)\"`. The PR description is one sentence: `This reverts commit f73f0d76cd4a1ec37acecf3e4ff8653714b4345f.` Three files reverted, 669 deletions, 42 insertions. The 335-line `security.test.ts` returned to 39 lines, the same shape it had after #8967.\n\nThe CHANGELOG for v2.0.41 still lists, in its bug-fixes section: `[Workflow: JavaScript] Fix security issue of script executing in node:vm mode (#9084) by @mytharcher`. The CHANGELOG entry was generated from the merged-PR list and does not mention #9176. The release notes for the version that reverted the fix still describe shipping the fix.\n\nThe hardening the second patch added is the hardening that would have closed the next bypass class. The class is named in the commit message: prototype-chain traversal via the return values of wrapped module functions, demonstrated against `crypto.createHash().update.constructor`. With #9084 reverted, that bypass is currently unmitigated in v2.0.41 and every release after.\n\n## The CVE arrived sixty-seven days after the patch.\n\nThe fix shipped March 27, 2026. CVE-2026-34156 was assigned and published June 2, 2026, with CVSS 9.9 and the vector `AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H`. The PoC at `Dhananjayasj/CVE-2026-34156-NocoBase-Sandbox-Escape-via-Workflow-Execution-Vulnerability-` is dated the same day. The README is signed `Author: Ashraf Zaryouh / 0xBlackash`, the original PoC author whose handle the script links back to.\n\nThe CVE record is filed against versions ≤ 2.0.27. v2.0.28 has the fix. There are sixty-seven days between the patch shipping and the bug having a name a defender can grep their SCA feed for. NocoBase is open-source and self-hosted; operators are responsible for upgrading. The CHANGELOG entry for v2.0.28 says \"Fix security issues\" with no description, no impact statement, no upgrade urgency, and no link to a security advisory page. There is no security advisory page.\n\n## The runtime exists because operators asked for it.\n\nThe `IsolatedVm.js` runtime exists. The `Vm.js` runtime exists. The codebase author wrote both, ships both, and selects between them on a single environment variable. The reason both exist is that the safe runtime does not support `require`. Operators who want to call `crypto.createHash` or `path.resolve` or anything else from a workflow script have to flip to `Vm.js`. That is the supported configuration.\n\nThe supported configuration is the unsafe one. The comment on the supported configuration says `unsafe; not a security boundary`. The patches harden the unsafe configuration. The patches close specific instances of the prototype-chain bypass: `console._stdout`, the return-value reach, the accessor-property leak. The Node.js `vm` module's own documentation, paragraph one, says no patch closes the class. NocoBase wrote a patch that closed the class, in #9084. NocoBase reverted it three days later, in #9176.\n\nThis is the [Unpatchable Primitive](/patterns/unpatchable-primitive) shape on its own author's source tree. The primitive is the use of `node:vm` as a sandbox. The same file is a [Design Debt Driver](/patterns/design-debt-driver): three security commits to `Vm.js` in two months, the deepest one reverted three days after shipping, with each patch closing the previous PoC's chain and leaving the next chain for the next PoC. The codebase calls one of its own files `unsafe`; the codebase is right. CVE-2026-34156 is the bug in the configuration the operator turned on when they wanted `require`.\n\nThe comment said unsafe. The CVE is what unsafe meant.\n\nPoC: [Dhananjayasj/CVE-2026-34156-NocoBase-Sandbox-Escape-via-Workflow-Execution-Vulnerability-](https://github.com/Dhananjayasj/CVE-2026-34156-NocoBase-Sandbox-Escape-via-Workflow-Execution-Vulnerability-)","closing_line":"The comment said unsafe. The CVE is what unsafe meant.","hook_md":"NocoBase ships two sandbox runtimes for its workflow JavaScript Script Node, and selects between them at startup on one environment variable. The codebase calls one runtime `IsolatedVm.js` and the other `Vm.js`. The comment on the selection logic, in `ScriptInstruction.ts`, reads, verbatim:\n\n```\n- WORKFLOW_SCRIPT_MODULES set: uses Node.js vm with require support (unsafe; not a security boundary)\n- WORKFLOW_SCRIPT_MODULES unset: uses isolated-vm for maximum security (no require, no Node.js APIs)\n```\n\nCVE-2026-34156 is the sandbox escape in the runtime NocoBase's own source code does not call a sandbox.","post_id":538,"slug":"nocobase-cve-2026-34156-codebase-said-unsafe","title":"CVE-2026-34156: NocoBase's Workflow Sandbox Is Marked Unsafe In Its Own Source","type":"initial","unreadable_sentence":"NocoBase wrote a patch that closed the class, in #9084. NocoBase reverted it three days later, in #9176."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCapr8CAAKCRDeZjl4jgkQ JvlCAP9j/LLgba/AsUk6JZc/NFOXM+Qh39TQXM2+53joIMe2xgEAnBiqL96o70JL pjElC20BoTzDpZ+vCYil/Q0kZH9+5wM= =FiO7 -----END PGP SIGNATURE-----