Bug 2154 - Avoid key lookup overhead when re-keying
Summary: Avoid key lookup overhead when re-keying
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sshd (show other bugs)
Version: -current
Hardware: All All
: P5 enhancement
Assignee: Damien Miller
URL:
Keywords:
: 2194 (view as bug list)
Depends on:
Blocks: V_6_7
  Show dependency treegraph
 
Reported: 2013-09-19 07:25 AEST by Iain Morgan
Modified: 2014-10-08 08:00 AEDT (History)
3 users (show)

See Also:


Attachments
Cache the host key and compare against it when re-keying (820 bytes, patch)
2013-09-19 07:25 AEST, Iain Morgan
no flags Details | Diff
Move code slightly and add a debug() statement (965 bytes, patch)
2013-09-19 09:24 AEST, Iain Morgan
no flags Details | Diff
Cache the key after the initial check (1.71 KB, patch)
2013-09-20 07:27 AEST, Iain Morgan
no flags Details | Diff
updated patch (1.66 KB, patch)
2014-07-03 14:21 AEST, Damien Miller
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Iain Morgan 2013-09-19 07:25:40 AEST
Created attachment 2337 [details]
Cache the host key and compare against it when re-keying

Proposal: Cache server host key after initial key exchange

Currently, whenever a key exchange is triggered, the host key offered by
the server must be verified. This may involve DNS queries or requests to
read the known hosts files. This can be problematic if
StrictHostKeyChecking is set to "yes" and the verification fails due to
a temporary problem, such as a corrupted /etc/ssh/ssh_known_hosts file.

It should also be noted that with increasing file transfer rates and
server-side support for time-based re-keying, the overhead of frequent
host key verification becomes more of an issue.

For example, consider an environment where /etc/ssh/ssh_known_hosts is
centrally managed and is the primary source for verifying the
authenticity of hosts. Further, assume that StrictHostKeyChecking is set
to "yes" and that a damaged copy of the ssh_known_hosts file is
distributed to the client systems. Existing ssh connections which re-key
while the damaged file is in place will fail to re-key and will then
disconnect. This will tend to impact high-bandwidth connections, such as
large file transfers or busy X11 sessions. It can also impact regular
login sessions if time-based re-keying is enabled.

To avoid these issues, it might be worthwhile to cache the host key used
during the initial key exchange. On subsequent key exchanges, the cached
copy of the previously verified host key could be compared against the
offered host key to avoid some of the overhead.

An initial patch has been attached to this bug, but I'm not sure if it
has unintended any side-effects.
Comment 1 Iain Morgan 2013-09-19 09:24:35 AEST
Created attachment 2338 [details]
Move code slightly and add a debug() statement
Comment 2 Darren Tucker 2013-09-19 10:29:40 AEST
idea seems reasonable.  I'm not sure I like the current implementation because the cached key is stored before all of the validation.
Comment 3 Iain Morgan 2013-09-20 07:27:42 AEST
Created attachment 2341 [details]
Cache the key after the initial check
Comment 4 Damien Miller 2013-12-05 11:57:41 AEDT
One downside that just occurred to me: caching the key will skip revoked keys checks. I'm not sure whether this matters, since relying on rekeying to detect compromised keys is pretty hit and miss anyway.
Comment 5 Damien Miller 2014-02-06 10:17:46 AEDT
Retarget incomplete bugs / feature requests to 6.6 release
Comment 6 Damien Miller 2014-02-06 10:19:38 AEDT
Retarget incomplete bugs / feature requests to 6.6 release
Comment 7 Damien Miller 2014-04-12 14:49:15 AEST
Retarget to 6.7 release, since 6.6 was mostly bugfixing.
Comment 8 Damien Miller 2014-04-12 14:53:45 AEST
Remove from 6.6 tracking bug
Comment 9 Damien Miller 2014-07-03 14:21:14 AEST
Created attachment 2450 [details]
updated patch

Update to -current
Comment 10 Damien Miller 2014-07-03 14:24:02 AEST
*** Bug 2194 has been marked as a duplicate of this bug. ***
Comment 11 Damien Miller 2014-07-04 08:24:03 AEST
applied - this will be in openssh-6.7. Thanks!
Comment 12 Damien Miller 2014-10-08 08:00:40 AEDT
Close all bugs left open from 6.6 and 6.7 releases.