cli-tunnel 1.2.0-beta.5 → 1.2.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +16 -49
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -603,27 +603,15 @@ async function main() {
603
603
  }
604
604
  catch { /* use as-is */ }
605
605
  }
606
- // F-07: Security — allowlist safe environment variables for PTY
607
- const SAFE_ENV_VARS = new Set([
608
- 'PATH', 'HOME', 'USERPROFILE', 'SHELL', 'TERM', 'LANG', 'LC_ALL', 'LC_CTYPE',
609
- 'USER', 'LOGNAME', 'EDITOR', 'VISUAL', 'COLORTERM', 'TERM_PROGRAM',
610
- 'HOSTNAME', 'COMPUTERNAME', 'PWD', 'OLDPWD', 'SHLVL', 'TMPDIR', 'TMP', 'TEMP',
611
- 'XDG_RUNTIME_DIR', 'XDG_DATA_HOME', 'XDG_CONFIG_HOME', 'XDG_CACHE_HOME',
612
- 'DISPLAY', 'WAYLAND_DISPLAY', 'DBUS_SESSION_BUS_ADDRESS',
613
- 'PROGRAMFILES', 'PROGRAMFILES(X86)', 'SYSTEMROOT', 'WINDIR', 'COMSPEC',
614
- 'APPDATA', 'LOCALAPPDATA', 'PROGRAMDATA',
615
- 'NODE_ENV',
616
- 'GOPATH', 'GOROOT', 'CARGO_HOME', 'RUSTUP_HOME',
617
- 'JAVA_HOME', 'MAVEN_HOME', 'GRADLE_HOME',
618
- 'PYTHONPATH', 'VIRTUAL_ENV', 'CONDA_DEFAULT_ENV',
619
- 'KUBECONFIG', 'DOCKER_HOST', 'DOCKER_CONFIG',
620
- 'GIT_AUTHOR_NAME', 'GIT_AUTHOR_EMAIL', 'GIT_COMMITTER_NAME', 'GIT_COMMITTER_EMAIL',
621
- 'HTTP_PROXY', 'HTTPS_PROXY', 'NO_PROXY', 'http_proxy', 'https_proxy', 'no_proxy',
622
- 'SSH_AUTH_SOCK', 'GPG_TTY',
623
- ]);
606
+ // F-07: Security — filter dangerous environment variables for PTY
607
+ // Blocklist approach: pass everything except known dangerous vars and secrets
608
+ const DANGEROUS_VARS = new Set(['NODE_OPTIONS', 'NODE_REPL_HISTORY', 'NODE_EXTRA_CA_CERTS',
609
+ 'NODE_PATH', 'NODE_REDIRECT_WARNINGS', 'NODE_PENDING_DEPRECATION',
610
+ 'UV_THREADPOOL_SIZE', 'LD_PRELOAD', 'DYLD_INSERT_LIBRARIES']);
611
+ const sensitivePattern = /token|secret|key|password|credential|api_key|private_key|access_key|connection_string|auth/i;
624
612
  const safeEnv = {};
625
613
  for (const [k, v] of Object.entries(process.env)) {
626
- if (SAFE_ENV_VARS.has(k) && v !== undefined) {
614
+ if (v !== undefined && !DANGEROUS_VARS.has(k) && !sensitivePattern.test(k)) {
627
615
  safeEnv[k] = v;
628
616
  }
629
617
  }
@@ -632,45 +620,24 @@ async function main() {
632
620
  cols, rows, cwd,
633
621
  env: safeEnv,
634
622
  });
635
- // Detect CSPRNG crash (Node.js 23 + node-pty issue) and retry via cmd.exe wrapper
623
+ // Detect CSPRNG crash (rare Node.js + PTY issue) and show helpful message
636
624
  let ptyExitedEarly = false;
637
625
  const earlyExitCheck = new Promise((resolve) => {
638
626
  ptyProcess.onExit(({ exitCode }) => {
639
- if (exitCode === 134 || exitCode === 3221226505) { // 134 = SIGABRT, 3221226505 = STATUS_BREAKPOINT
627
+ if (exitCode === 134 || exitCode === 3221226505) {
640
628
  ptyExitedEarly = true;
641
629
  resolve();
642
630
  }
643
631
  });
644
- setTimeout(resolve, 2000); // Wait 2s — if still running, it's fine
632
+ setTimeout(resolve, 2000);
645
633
  });
646
634
  await earlyExitCheck;
647
- if (ptyExitedEarly && process.platform === 'win32') {
648
- console.log(` ${YELLOW}⚠${RESET} CSPRNG crash detected (Node.js + PTY issue), retrying via cmd.exe wrapper...\n`);
649
- // Spawn through cmd.exe /c this adds a shell layer that avoids the crash
650
- const cmdLine = [resolvedCmd, ...commandArgs].map(a => a.includes(' ') ? `"${a}"` : a).join(' ');
651
- ptyProcess = nodePty.spawn('cmd.exe', ['/c', cmdLine], {
652
- name: 'xterm-256color',
653
- cols, rows, cwd,
654
- env: safeEnv,
655
- });
656
- // Check if cmd.exe wrapper also fails
657
- let retryFailed = false;
658
- const retryCheck = new Promise((resolve) => {
659
- ptyProcess.onExit(({ exitCode }) => {
660
- if (exitCode === 134 || exitCode === 3221226505) {
661
- retryFailed = true;
662
- resolve();
663
- }
664
- });
665
- setTimeout(resolve, 2000);
666
- });
667
- await retryCheck;
668
- if (retryFailed) {
669
- const nodeVer = process.version;
670
- console.log(` ${YELLOW}⚠${RESET} The command crashed due to a known Node.js ${nodeVer} + PTY compatibility issue.`);
671
- console.log(` ${BOLD}Fix:${RESET} Install Node.js 22 LTS: ${GREEN}nvm install 22${RESET} or ${GREEN}winget install OpenJS.NodeJS.LTS${RESET}\n`);
672
- process.exit(1);
673
- }
635
+ if (ptyExitedEarly) {
636
+ const nodeVer = process.version;
637
+ console.log(` ${YELLOW}⚠${RESET} The command crashed (CSPRNG assertion failure).`);
638
+ console.log(` This is a known issue with Node.js ${nodeVer} + PTY on Windows.`);
639
+ console.log(` ${BOLD}Fix:${RESET} Install Node.js 22 LTS: ${GREEN}nvm install 22${RESET} or ${GREEN}winget install OpenJS.NodeJS.LTS${RESET}\n`);
640
+ process.exit(1);
674
641
  }
675
642
  ptyProcess.onData((data) => {
676
643
  process.stdout.write(data);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cli-tunnel",
3
- "version": "1.2.0-beta.5",
3
+ "version": "1.2.0-beta.7",
4
4
  "description": "Tunnel any CLI app to your phone — PTY + devtunnel + xterm.js",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",