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.
- package/dist/index.js +16 -49
- 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,45 +620,24 @@ 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 }) => {
|
|
639
|
-
if (exitCode === 134 || exitCode === 3221226505) {
|
|
627
|
+
if (exitCode === 134 || exitCode === 3221226505) {
|
|
640
628
|
ptyExitedEarly = true;
|
|
641
629
|
resolve();
|
|
642
630
|
}
|
|
643
631
|
});
|
|
644
|
-
setTimeout(resolve, 2000);
|
|
632
|
+
setTimeout(resolve, 2000);
|
|
645
633
|
});
|
|
646
634
|
await earlyExitCheck;
|
|
647
|
-
if (ptyExitedEarly
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
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);
|