Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions src/cli-kex.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,11 +368,15 @@ static void checkhostkey(const unsigned char* keyblob, unsigned int keybloblen)

/* Compare hostnames */
if (strncmp(cli_opts.remotehost, (const char *) buf_getptr(line, hostlen),
hostlen) != 0) {
hostlen) == 0) {
/* We have matched the full cli hostname */
buf_incrpos(line, hostlen);
} else if (buf_getbyte(line) == '*') {
/* We have matched a * wildcard */
} else {
continue;
}

buf_incrpos(line, hostlen);
if (buf_getbyte(line) != ' ') {
/* there wasn't a space after the hostname, something dodgy */
TRACE(("missing space afte matching hostname"))
Expand Down Expand Up @@ -400,16 +404,6 @@ static void checkhostkey(const unsigned char* keyblob, unsigned int keybloblen)
goto out;
}

/* The keys didn't match. eep. Note that we're "leaking"
the fingerprint strings here, but we're exiting anyway */
dropbear_exit("\n\n%s host key mismatch for %s !\n"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warning and exit should still occur if there are matching hostnames but none of the keys match. Otherwise an intercepted known connection would just show the same "accept new hostkey" prompt which mightn't be noticed.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good point. I will rework it to give the warning after the loop if there have been any non-wildcard hostname matches

"Fingerprint is %s\n"
"Expected %s\n"
"If you know that the host key is correct you can\nremove the bad entry from ~/.ssh/known_hosts",
algoname,
cli_opts.remotehost,
sign_key_fingerprint(keyblob, keybloblen),
fingerprint ? fingerprint : "UNKNOWN");
} while (1); /* keep going 'til something happens */

/* Key doesn't exist yet */
Expand Down