cli-tunnel 1.2.0-beta.6 → 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.
- package/dist/index.js +14 -96
- 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 —
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
'
|
|
610
|
-
'
|
|
611
|
-
|
|
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 (
|
|
614
|
+
if (v !== undefined && !DANGEROUS_VARS.has(k) && !sensitivePattern.test(k)) {
|
|
627
615
|
safeEnv[k] = v;
|
|
628
616
|
}
|
|
629
617
|
}
|
|
@@ -632,7 +620,7 @@ async function main() {
|
|
|
632
620
|
cols, rows, cwd,
|
|
633
621
|
env: safeEnv,
|
|
634
622
|
});
|
|
635
|
-
// Detect CSPRNG crash (Node.js
|
|
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 }) => {
|
|
@@ -644,82 +632,12 @@ async function main() {
|
|
|
644
632
|
setTimeout(resolve, 2000);
|
|
645
633
|
});
|
|
646
634
|
await earlyExitCheck;
|
|
647
|
-
if (ptyExitedEarly
|
|
648
|
-
|
|
649
|
-
console.log(` ${YELLOW}⚠${RESET}
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
'UV_THREADPOOL_SIZE', 'LD_PRELOAD', 'DYLD_INSERT_LIBRARIES']);
|
|
654
|
-
const fullSafeEnv = {};
|
|
655
|
-
for (const [k, v] of Object.entries(process.env)) {
|
|
656
|
-
if (!DANGEROUS_VARS.has(k) && v !== undefined)
|
|
657
|
-
fullSafeEnv[k] = v;
|
|
658
|
-
}
|
|
659
|
-
ptyProcess = nodePty.spawn(resolvedCmd, commandArgs, {
|
|
660
|
-
name: 'xterm-256color',
|
|
661
|
-
cols, rows, cwd,
|
|
662
|
-
env: fullSafeEnv,
|
|
663
|
-
});
|
|
664
|
-
let retry1Failed = false;
|
|
665
|
-
const retry1Check = new Promise((resolve) => {
|
|
666
|
-
ptyProcess.onExit(({ exitCode }) => {
|
|
667
|
-
if (exitCode === 134 || exitCode === 3221226505) {
|
|
668
|
-
retry1Failed = true;
|
|
669
|
-
resolve();
|
|
670
|
-
}
|
|
671
|
-
});
|
|
672
|
-
setTimeout(resolve, 2000);
|
|
673
|
-
});
|
|
674
|
-
await retry1Check;
|
|
675
|
-
if (retry1Failed) {
|
|
676
|
-
// Retry 2: cmd.exe wrapper with full env
|
|
677
|
-
console.log(` ${YELLOW}⚠${RESET} Still crashing, retrying via cmd.exe wrapper...\n`);
|
|
678
|
-
const cmdLine = [resolvedCmd, ...commandArgs].map(a => a.includes(' ') ? `"${a}"` : a).join(' ');
|
|
679
|
-
ptyProcess = nodePty.spawn('cmd.exe', ['/c', cmdLine], {
|
|
680
|
-
name: 'xterm-256color',
|
|
681
|
-
cols, rows, cwd,
|
|
682
|
-
env: fullSafeEnv,
|
|
683
|
-
});
|
|
684
|
-
let retry2Failed = false;
|
|
685
|
-
const retry2Check = new Promise((resolve) => {
|
|
686
|
-
ptyProcess.onExit(({ exitCode }) => {
|
|
687
|
-
if (exitCode === 134 || exitCode === 3221226505) {
|
|
688
|
-
retry2Failed = true;
|
|
689
|
-
resolve();
|
|
690
|
-
}
|
|
691
|
-
});
|
|
692
|
-
setTimeout(resolve, 2000);
|
|
693
|
-
});
|
|
694
|
-
await retry2Check;
|
|
695
|
-
if (retry2Failed) {
|
|
696
|
-
// Retry 3: useConpty: false with full env
|
|
697
|
-
console.log(` ${YELLOW}⚠${RESET} Still crashing, retrying with legacy PTY backend...\n`);
|
|
698
|
-
ptyProcess = nodePty.spawn(resolvedCmd, commandArgs, {
|
|
699
|
-
name: 'xterm-256color',
|
|
700
|
-
cols, rows, cwd,
|
|
701
|
-
env: fullSafeEnv,
|
|
702
|
-
useConpty: false,
|
|
703
|
-
});
|
|
704
|
-
let retry3Failed = false;
|
|
705
|
-
const retry3Check = new Promise((resolve) => {
|
|
706
|
-
ptyProcess.onExit(({ exitCode }) => {
|
|
707
|
-
if (exitCode === 134 || exitCode === 3221226505) {
|
|
708
|
-
retry3Failed = true;
|
|
709
|
-
resolve();
|
|
710
|
-
}
|
|
711
|
-
});
|
|
712
|
-
setTimeout(resolve, 2000);
|
|
713
|
-
});
|
|
714
|
-
await retry3Check;
|
|
715
|
-
if (retry3Failed) {
|
|
716
|
-
const nodeVer = process.version;
|
|
717
|
-
console.log(` ${YELLOW}⚠${RESET} The command crashed due to a known Node.js ${nodeVer} + PTY compatibility issue.`);
|
|
718
|
-
console.log(` ${BOLD}Fix:${RESET} Install Node.js 22 LTS: ${GREEN}nvm install 22${RESET} or ${GREEN}winget install OpenJS.NodeJS.LTS${RESET}\n`);
|
|
719
|
-
process.exit(1);
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
}
|
|
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);
|
|
723
641
|
}
|
|
724
642
|
ptyProcess.onData((data) => {
|
|
725
643
|
process.stdout.write(data);
|