security(ssh,sudo,keys): fix Sudo stdin leak, SSHPool Panic Lock/ProxyJump races, multi-algo known_hosts & OpenSSH import
This commit is contained in:
parent
9a27525def
commit
716627afdd
7 changed files with 944 additions and 151 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue