fix: host key silently accepted when the host is missing from the database (#1397)

This commit is contained in:
LukeGus committed 2026-10-03 16:35:09 -05:00
1 parent 44be18988b
commit b3e220acf1
2 files changed
+75 -2

No files matched your search

+31 -2
View File
@@ -84,18 +84,47 @@ export class SSHHostKeyVerifier {
hostId,
);
// No row means nothing to compare against and nowhere to save the
// key, so it is never accepted silently (#1397): the user decides
// when there is a socket to ask on, otherwise it is refused.
if (!host) {
if (!ws) {
sshLogger.error(
"Host not found in database during key verification, rejecting",
{
operation: "host_key_no_host",
hostId,
ip,
port,
userId,
},
);
verify(false);
return;
}
const accepted = await this.promptUserForNewKey(
ws,
ip,
port,
undefined,
fingerprint,
keyType,
algorithm,
);
sshLogger.warn(
"Host not found in database during key verification",
accepted
? "Key for a host missing from the database accepted for this session only"
: "Key for a host missing from the database rejected",
{
operation: "host_key_no_host",
hostId,
ip,
port,
fingerprint,
userId,
},
);
verify(true);
verify(accepted);
return;
}