OpenSSH and keystroke timings
Theoretical security weaknesses have a tendency to move from the realm of theory to that of practice over time. Sometimes it is the result of more compute power being applied or better algorithms being developed, but a weakness is certainly not going to get stronger. So when Kevin Neff started discussing fixing a weakness in OpenSSH on the openbsd-misc mailing list, the folks writing it off as "theoretical" may have been jumping the gun.
When it is in interactive mode—a user typing into a terminal session for example—ssh sends each key pressed by the user in a separate packet. By observing the timing between packets, an observer may be able to determine something about what was typed just by using traffic analysis, without attempting to break the encryption. Researchers found that the inter-packet timing correlated well with the inter-keystroke timing, so that using statistical techniques they were able to reduce the search space for cracking a password by a factor of 50.
This weakness was outlined in a 2001 paper entitled Timing analysis of keystrokes and timing attacks on SSH" [PDF] which looked specifically at the timing-based attack:
The paper looked at the now-deprecated SSH1 protocol, which led some to conclude that it substantially invalidated the weakness. Damien Miller pointed out that it was likely to still be valid:
Pointing at the paper and discounting it because it is ssh1 only is sticking your head in the sand. It is usually easier to research attacks on simpler protocols and work up to more complicated ones later.
There is a fair amount of information that can be gleaned just by looking at the traffic generated over an encrypted session, especially if the attacker can gather a sizable amount of it. There are fairly clear patterns in interactive sessions that can be extracted and used alongside the inter-keystroke timing information to potentially garner lots of useful information. Darrin Chandler describes it this way:
Overall, the reception to making OpenSSH less susceptible to this kind of analysis was positive. It is clearly a difficult attack to mount, logistically if nothing else, but it is not impossible either. Better timing information or analysis techniques might make it easier over time as well and that is enough of a reason to look at ways to fix it.
Index entries for this article | |
---|---|
Security | OpenSSH |
Posted Sep 18, 2008 3:17 UTC (Thu)
by flewellyn (subscriber, #5047)
[Link] (2 responses)
Overall, the reception to making OpenSSH less susceptible to this kind of analysis was positive. It was? When last I checked the thread logs on Kerneltrap, the general sense I saw was that most of the OpenSSH and OpenBSD folks were unconcerned to the point of hostility to the idea of preventing this kind of attack. Has that changed in the last day or so?
Posted Sep 18, 2008 14:47 UTC (Thu)
by smoogen (subscriber, #97)
[Link] (1 responses)
Posted Sep 19, 2008 6:02 UTC (Fri)
by djm (subscriber, #11651)
[Link]
Posted Sep 18, 2008 3:35 UTC (Thu)
by bronson (subscriber, #4806)
[Link] (8 responses)
And inserting a random delay between keystrokes would be pretty annoying when typing your user name... Yeah, I guess that's not an easy problem to solve!
Posted Sep 18, 2008 4:38 UTC (Thu)
by shapr (subscriber, #9077)
[Link] (1 responses)
My next thought is "try to use backspace in your password." Though that could also be found out if you always use backspace in the same position.
I suspect that use of dvorak or some other non-qwerty keyboard might make this a tetch more difficult.
Posted Sep 18, 2008 5:30 UTC (Thu)
by eru (subscriber, #2753)
[Link]
Suppose ssh introduced a line-by-line mode, where editing like
backspace can be done locally by the ssh client? This would of
course require that all software you are trying to feed passwords
to will co-operate in setting the line-mode. Maybe this would
even need a new stty mode?
In the age of dinosaurs, these kinds of line-by-modes were normal
on non-Unix systems. In fact it was quite uncommon for apps to react to
individual characters from terminals. Editing was handled by "smart
terminals" or front-end machines, which fed complete lines (or even
complete filled forms) to The Real Computer.
Posted Sep 18, 2008 4:54 UTC (Thu)
by jimbo (guest, #6689)
[Link] (1 responses)
It might be practicable to add noise into the plain text of a short packet, encrypt the whole thing (including the noise). The packet can then be decrypted, and the actual data extracted for use by the application.
Posted Sep 18, 2008 7:15 UTC (Thu)
by bboissin (subscriber, #29506)
[Link]
Posted Sep 18, 2008 7:20 UTC (Thu)
by dlang (guest, #313)
[Link] (2 responses)
do you _really_ want your transport layer to start guessing at what strings may be password prompts that should shift you into line-based mode instead of character mode? what if that string shows up in the middle of an image while you are playing a game, do you really want it to start buffering all your keystrokes (and not showing you) until you hit enter?
the only fix for this is to waste bandwidth by sending garbage packets.
my solution, try to sidestep the problem by using hardware token based authentication wherever possible rather then passwords (even over encrypted links)
Posted Sep 18, 2008 8:53 UTC (Thu)
by epa (subscriber, #39769)
[Link] (1 responses)
Posted Sep 18, 2008 18:18 UTC (Thu)
by djm (subscriber, #11651)
[Link]
Posted Sep 18, 2008 15:52 UTC (Thu)
by docwhat (guest, #40373)
[Link]
The problem is that if you ssh from a to b. Then ssh from b to c. If someone eavesdrops on your a-b connection, they will see the password for c being typed.
Ciao!
Posted Sep 18, 2008 8:02 UTC (Thu)
by alex (subscriber, #1355)
[Link] (1 responses)
Posted Sep 18, 2008 18:21 UTC (Thu)
by djm (subscriber, #11651)
[Link]
The problem is keystrokes typed once the session is up, e.g. your password after running "sudo". We already have measures in place to make it difficult for an eavesdropper to know when you are typing such a password, but they could still perform traffic analysis on the entire session.
Posted Sep 18, 2008 15:23 UTC (Thu)
by felixfix (subscriber, #242)
[Link] (6 responses)
It would introduce some weird latency. But I think it would be fairly easy to try, and some experimenting would show whether an interval small enough to be bother-free would send multiple keys.
You could even make it a lower and upper bound, and it would choose a random interval between them for each packet.
I wonder how much difference this would make in the entropy.
I personally don't think a 100 ms interval would be very obnoxious. The weird part would be its burstiness, which might make 100ms too hard to get used to. But if you pick an interval that sometimes sends two or even three keys, that should be enough. Well, but then you might have packets every interval for several intervals, then skip one or two, then a few more, and that might be a clue that the skipped packets were due to quickly typed keys having been combined in the previous or next packets :-)
Posted Sep 18, 2008 15:55 UTC (Thu)
by docwhat (guest, #40373)
[Link] (2 responses)
You could also randomly time shift keys characters by a 1ms or two every so often. I don't think a user would notice that.
Ciao!
Posted Sep 18, 2008 18:17 UTC (Thu)
by felixfix (subscriber, #242)
[Link] (1 responses)
Posted Sep 18, 2008 19:29 UTC (Thu)
by docwhat (guest, #40373)
[Link]
Ideally, the packets should be the same size, so keys and chaff should both be the same structure except that the chaff has an extra bit saying it's chaff.
An alternative that may be implementable now (I don't know much about the SSHv2 protocol) is to use a bogus encryption key so that it is rejected on the receiving side. That'll add additional confusion to anyone trying to break the stream as they'll have to separate the differently encrypted packets from one another.
Ciao!
Posted Sep 18, 2008 18:22 UTC (Thu)
by djm (subscriber, #11651)
[Link] (2 responses)
Posted Sep 19, 2008 0:20 UTC (Fri)
by gmaxwell (guest, #30048)
[Link] (1 responses)
Tricks like this sound nice but try proving that they actually stop the information leak. As far as I'm aware nothing short of padding to a full constant information rate has ever been proven to stop information leaks from timing in systems where they have been considered (anonymous remailers, onion networks).
Since we're already talking about a somewhat obscure (though, no doubt, real) vulnerability it's probably not worth adding complexity for a half solution which can not be proven to completely close the hole.
To me the obvious solution to this would be to extend ssh agent to supporting more types of authentication, and allowing programs other than SSH to make use of that functionality. Timing attack immunity would fall out as a nice side-effect but greater robustness against compromised jump hosts would also be a benefit, as well as the ability to provide things like smart-card authentication across multi-hop ssh connections.
Beyond the basic SSH-via-SSH or SUDO-(PAM)-via-SSH) cases it would take some time for applications to be updated to take advantage of this functionality, so it wouldn't be an overnight fix, but we've lived with this vulnerability this long so a bit longer waiting for the right fix shouldn't kill anyone.
Posted Sep 19, 2008 6:00 UTC (Fri)
by djm (subscriber, #11651)
[Link]
OpenSSH and keystroke timings
OpenSSH and keystroke timings
OpenSSH and keystroke timings
OpenSSH and keystroke timings
OpenSSH and keystroke timings
My next thought is "try to use backspace in your password."
Back to line-by-line input...
OpenSSH and keystroke timings
--
Jimbo
OpenSSH and keystroke timings
not really
not really
how would ssh know that you are sending a password?
Password prompts already send special magic characters to the tty to turn off echoing. It would need only a small extension to su(1) or ssh(1) to make them echo a new sequence meaning 'I am reading a password now'. The remote ssh client would note this and batch up a whole line of input to send at once.
not really
OpenSSH and keystroke timings
One more reason...
One more reason...
Buffer keys at 100 ms intevals
Buffer keys at 100 ms intevals
Buffer keys at 100 ms intevals
Buffer keys at 100 ms intevals
Buffer keys at 100 ms intevals
Buffer keys at 100 ms intevals
Buffer keys at 100 ms intevals