security(ssh,sudo,keys): fix Sudo stdin leak, SSHPool Panic Lock/ProxyJump races, multi-algo known_hosts & OpenSSH import

This commit is contained in:
tyuXX 2026-11-27 22:40:40 +00:00
parent 9a27525def
commit 716627afdd
7 changed files with 944 additions and 151 deletions

View file

@ -401,7 +401,27 @@ export class MockSshServer {
let stdin = rawStdin;
// Handle sudo wrappers produced by prepareSudoExecution
if (command.startsWith("sudo -S -p '' sh -c ")) {
if (command.startsWith("sudo -S -k -p '' sh -c ")) {
const nl = stdin.indexOf('\n');
const suppliedPw = nl >= 0 ? stdin.slice(0, nl) : stdin;
this.lastSudoStdin = suppliedPw;
stdin = nl >= 0 ? stdin.slice(nl + 1) : '';
if (this.options.sudoPassword && suppliedPw !== this.options.sudoPassword) {
return { stdout: '', stderr: 'sudo: incorrect password', exitCode: 1 };
}
command = unquoteSinglePosix(command.slice("sudo -S -k -p '' sh -c ".length));
} else if (command.startsWith("sudo -S -k -p '[gcoord-sudo-prompt] ' sh -c ")) {
const nl = stdin.indexOf('\n');
const suppliedPw = nl >= 0 ? stdin.slice(0, nl) : stdin;
this.lastSudoStdin = suppliedPw;
stdin = nl >= 0 ? stdin.slice(nl + 1) : '';
if (this.options.sudoPassword && suppliedPw !== this.options.sudoPassword) {
return { stdout: '', stderr: 'sudo: incorrect password', exitCode: 1 };
}
command = unquoteSinglePosix(
command.slice("sudo -S -k -p '[gcoord-sudo-prompt] ' sh -c ".length),
);
} else if (command.startsWith("sudo -S -p '' sh -c ")) {
const nl = stdin.indexOf('\n');
const suppliedPw = nl >= 0 ? stdin.slice(0, nl) : stdin;
this.lastSudoStdin = suppliedPw;