Auditing GitHub users’ SSH key quality
blog.benjojo.co.uk
blog.benjojo.co.uk
As the article says, GitHub could be being proactive rather than reactive here. They don't "have" to, but they could.
> Thanks to our new servers, known bad keys[2] from Debian and Ubuntu are now blacklisted. We estimate that about 1000 keys in our database were impacted by this. If you get authentication errors using keys that worked a day ago, please double-check that they are not on our blacklist. If they are, you should ensure your software is updated and generate new keys. We’ve got a guide to help you out with this.
[1] https://github.com/blog/500-state-of-the-hub-rackspace-day-0
[2] https://github.com/blog/63-ssh-keys-generated-on-debian-ubun...
The answers were yes and no. It's the same for most systems right now. You can put a weak Debian key in authorised keys, but you won't be able to login anyway.
If you want to check how many bits your key is, use
ssh-keygen -l -f ~/.ssh/your_key.pub
(It wasn't mine, while it is an older key, mine is larger than 768 thankfully)
Edit: look at timdorr's example for a better visual.
ssh-keygen -l -f ~/.ssh/id_rsa.pub
You'll get an output like so: ⚡~ $ ssh-keygen -l -f ~/.ssh/id_rsa.pub
2048 f6:2d:94:54:c0:96:18:64:24:fb:c2:ad:ed:6a:1d:68 timdorr@Pixelicious.local (RSA) 4096 63:f2:23:00:c9:0d:07:3b:6d:ad:4d:a9:98:32:f5:25 ***@*** (RSA)
Am I good?is this something we should be upgrading (like to 4096) in the near future?
- 180x per doubling bit size would be - 512 doubled twice, would mean 3 days * 180 * 180 = 97,200 days
I think you're safe.
First, 2048 bits is not 512 bits doubled twice, but rather doubled 1536 times (512 doubled twice would be 514). If this were a symmetric cipher, you could stop here and conclude that a 2048 bit key was 2^1536 times stronger than a 512 bit key.
However, RSA has diminishing returns on security as you increase the key length. The strength is determined by the complexity of the GNFS, the fastest known way of breaking RSA[1]. That tells us that breaking 256-bit RSA takes ~2^46 operations, 512-bit RSA takes ~2^63, 2048-bit RSA takes ~2^116, and 4096-bit RSA takes ~2^156. 2^116 is a lot of operations - they say the amount of energy required to break that would be nearly enough to boil all the water on earth.
[1] http://crypto.stackexchange.com/questions/8687/security-stre...
Not wanting to be alarmist, but what you're saying is that someone breaking my ssh key (which is 2048 bits) is the end of the world...
As with RSA, this command generates a public and private key file. Put the public key in the authorized_keys file on the server side.
You'll need OpenSSH 6.4 on both the server and the client side. If you have an older version, I would not recommend upgrading outside of your operating system's normal upgrade channel because then you'll be responsible for security updates. Instead I would wait until your operating system has it.
$ ssh-keygen -t ed25519
As usual, on the server, you do something like $ cat generated-key.pub >> ~you/.ssh/authorized_keys
EDIT: sibling post was quicker off the bat. Oh well, that'll teach me to not refresh a tab :p for file in $(ls ~/.ssh/*.pub); do ssh-keygen -lf $file; done find ~/.ssh -name '*.pub' | xargs ssh-keygen -lf
Here's a simple bash function to check all your GitHub keys: function check_github_keys {
username=$1
i=0
curl -sw "\n" "https://github.com/${username}.keys" | while IFS="\n" read -r line ; do
tmp=`mktemp -t githubkey`;
echo "$line" > $tmp
res=$(ssh-keygen -lf $tmp)
rm $tmp
((i=i+1))
echo "${username}.keys:${i} ${res/ $tmp/}"
done
}
Invoke as: check_github_keys <username>
I'm sure there's a better way to write that one though!find ~/.ssh -name '*.pub' -print0 | xargs -0 ssh-keygen -lf
ssh-add -l
to list all your registered keys.Is there outdated ssh keygen software out there that still generates sub-768 keys?
Or perhaps someone has a system that generates keys automatically, and it was poorly configured.
Even then, generating such key with OpenSSH was not something one could do by accident.
IIRC PuTTYGen had a bug in it for a very long time that you would ask for a 1024 key, and it would subtract a bit off it. You can see the same with 2047 keys in the data that I will be publishing on the next post.
It was a key generated and used as a test (years ago). It has never been used to access my Github account. Also, my account is pretty bare as it is.
To be safe, though, I have now removed the key.
Post the private key to prove it!
From a healthy paranoid point of view: you don't share your public key unless you have to. Sure, there are no known attacks on strong RSA keys today, but that doesn't mean there will never be. Why take that risk with, literally, thousands of keys and people's security? It's rude at the very least.
Of course, you should never use your Github keys for anything else, but that's beside the point entirely.
As for the comments: key comments are useful but often contain information that can identify a person (e-mail address, username@machine etc). Publishing that would have been even worse.
I would say it encourages scrutiny. The assumption of public keys is that they are public, if any part of your security architecture relies on a public key being private then it would seem flawed, flaws that should be exposed.
And if them being public induces extra paranoia, such as using separate keys only for github then all the better.
Sunlight is the best disinfectant.
These keys are not less secure for being published, but moreso. At least now the public can determine whether or not we trust these keys and any edits made with them as opposed to weaknesses in their security going abused without notice.
But it's just metadata, isn't it..
something like the following in ~/.ssh/config
Host *.github.com
IdentitiesOnly yes
IdentityFile ~/.ssh/hostboundkeys/github_ed25519
You only need one private key per device to be secure. The benefit of using separate keys per service is privacy - it prevents the various service providers from colluding to determine that you're a user of all the services (but if you're not careful you're probably leaking other information to them that would let them learn this anyways).
I agree with the privacy aspect, it's that's the same point that the8472 made.
It's not "strictly better" when it hurts your ability to use and memorize strong passes.
Usability is part of security.
# IdentityFile magic, should be placed at very end of file
Host *
IdentityFile ~/.ssh/keys/id_ecdsa_%r@%h
IdentityFile ~/.ssh/keys/id_rsa_%r@%h
IdentityFile ~/.ssh/keys/id_ecdsa_ANY@%h
IdentityFile ~/.ssh/keys/id_rsa_ANY@%h
IdentityFile ~/.ssh/keys/id_ecdsa_%r@ANY
IdentityFile ~/.ssh/keys/id_rsa_%r@ANY
IdentityFile ~/.ssh/keys/id_ecdsa_ANY@ANY
IdentityFile ~/.ssh/keys/id_rsa_ANY@ANY
Will look for user@host, ANY@host, user@ANY, then ANY@ANY keys. You can add ed25519 to this.At least, I can't imagine memorising enough unique passphrases for all the user/host combinations I currently have.
I'm hoping there's some clever built-in or easily added (like keychain/agent) way to secure individual keys on the filesystem without excess complexity when using them.
Normally, the problem with having many keys in the agent is that a server you're logging into will boot you after supplying too many keys it doesn't accept, but this fixes that.
What about your privacy architecture? Can the public key be derived from a packet capture of SSH? My quick session with Wireshark and layman's protocol/crypto understanding says probably not. But it seems possible that while the crypto may be designed such that the public key may be public without endangering the cryptography, there are still privacy reasons (being able to identify people by unique public key) to not share it any more widely than it needs to be.
For example, it seems like I have read that PGP public keys can be read in the clear, which allows metadata graphs to be built by passive interceptors. Maybe SSH doesn't have that issue though.
By publishing the key you expose the flaw in that setup.
If that applies to SSH, I see no problem in asking for "public key secrecy" as a requirement/option in a layer above the crypto.
That means the public key will not be leaked to outside observers. Combine with server-specific keys to avoid potential "try logging into my server" social engineering.
This means only the server will ever learn your public key, but it has to know that already anyway.
So publishing your public key does not leak any privacy bits.
Did your dad ever come into your room and throw open the curtains to get you to get your lazy ass out of bed?
Today you know he was probably right, but how did you feel about it when it was happening? Probably not very good.
If your security model relies on public keys not being publicly known, then your security model can't reasonably be expected to work or be honored by GitHub.
Considering a public key as a "shared secret", as you're claiming it is, moves beyond "healthy paranoid" and into just "paranoid".
If the developer is using the same key with both accounts, GitHub knows about the connection between them, but the larger public doesn't -- until the keys are published.
Another possible source of risk that would relate more to publishing the comment fields (which GitHub apparently chose not to do) is letting an attacker know which client devices to try to steal or compromise in order to get access to a developer's account. (Not a cryptographic attack at all!) It might still be possible to make some guesses about this if you know, for instance, that a developer bought a new laptop in a given week and then added a new key and either did or did not deactivate the old one.
Public keys that are used for confidential communications from the public or for signing publicly-released data probably ought to be distributed widely. But public keys that are used to authenticate to a service also reveal nonpublic facts about the number and activation and deactivation of devices that are used to access that service. If someone is crawling these records and noticing the timing of changes, it may help for planning attacks -- again, noncryptographic ones.
They shouldn't be doing that, though. Each public key should be tied to one identity. (You might have many keys to one identity, but not vice versa.)
I'll reiterate - you should assume your public key (and any comment on your public key) is already public information, even if GitHub hasn't published your pub key. Anything else is not good security practice.
As far as I can tell, this is not a concern to anyone in crypto -- revealing public keys, that is. Obviously if you're a crypto expert reading this and disagreeing, feel free to chime in, but as far as I know, there are zero concrete crypto reasons to obfuscate a public key.
It's your fault if you put private information in a public key's comment field.
You can send someone else’s public key to an old-style keyserver. Although you might think this would be a favor, it’s actually extremely rude. The public key owner might have reasons for not using a keyserver and might prefer to distribute his public key via some other method—or he might not want to publicize the key at all beyond a small group of people.
Never publicize someone else’s key for them!
Now, if your reply reiterates your argument that public keys are public because it's in the name, duh, then I can't help..
Any security model that relies on a public key not being known is a bad security model.
How "rude" an activity is only matters when you're dealing with people who care if you think they're being "rude", and in PKI that's not possible because your public key must be given to untrusted parties.
What's more relevant is the attack surface you present by exposing your public key. Since your security model already assumes they have it through other means, you've given your attacker no new information.
Hiding your public key is textbook "security through obscurity".
Edit: I tweeted the author of the quote you gave (Michael W. Lucas, @mwlauthor) about the above article, I'll try and get him to chime in on our discussion if I can.
Unless you're assuming they don't have it via other means. If I have a keypair I only use for GitHub, and GitHub didn't publish pubkeys as they do, then it is a fairly safe assumption that an attacker does not have my public key. Not something to build an entire cryptosystem around, but still a fairly safe assumption.
But I do agree when you say, "Any security model that relies on a public key not being known is a bad security model". It's the difference between "rely" and "this (weak) assumption contributes positively to overall security".
Let's look at a scenario. Say I:
1. use a particular keypair just for GitHub, and nothing else.
2. had generated this key on Debian during the period when it was brokenly generating easily-factorable keys with low entropy.
If GitHub did not publish public keys, then I could then reasonably expect that I was safe for the life of that key. Yes, upon finding out about the vulnerability, I'd immediately revoke and generate a new key, but there were people who unknowingly had vulnerable keys up there for a very long time, and they could have been compromised for a long time, without their knowledge.
Again, no, you can't rely on the public key being private, but publishing it can have some bad side-effects when something unforeseen comes up, and not publishing it can offer you some greater protection than publishing it, even if it's a small amount.
Having said that, I actually don't disagree with GitHub's decision to publish public keys as they do. So: shrug.
Never, ever assume this of your public key.
The solution to the Debian bug is to use a keypair not generated by the bugged Debian build, not "continue to use the bugged keypair".
Why? I mean, I'm not saying it's an absolute 100% certain assumption that any particular public key is secret. I'm saying it's a reasonable assumption that will likely be correct in many cases. Not something to base your faith of a cryptosystem on, of course, but it's a reasonable assumption in many circumstances that can have a positive impact on the actual security of your accounts. The public key I use for my own machines is very unlikely to be known by anyone else, because it's only used on machines I have full and sole control over. Sure, that's not absolute proof (maybe one of my servers has been compromised and I don't know about it), but it's a reasonable assumption.
The solution to the Debian bug is to use a keypair not generated by the bugged Debian build, not "continue to use the bugged keypair".
Duh. If you actually read what I wrote, you'd see I agree with that. I'm talking about the fact that people were using broken keypairs for long time, and didn't know, because the vulnerability hadn't been found and disclosed yet. You won't generate a new keypair if you don't know there's something wrong with the one you have.
My point is that if an attacker knew about the vulnerability a long time before it was fixed and publicly disclosed, GitHub publishing public keys gives that attacker a nice corpus of keys they can check to see if they're vulnerable, and can make use of that information (since the attacker knows that any bad key is known to be used for a particular GH account).
If GH did not publish public keys, all users would have been safe from that particular attack vector. Sure, there are other avenues where an attacker could get ahold of some of those same public keys, but it's probably a vanishingly small percentage of them.
I don't think so, because of the way GitHub's SSH access works - you don't need to know the account associated with a given key to try and authenticate with that key, so trying all 32k "Debian keys" of each size and seeing which ones let you in is quite feasible.
It seems to me that in crypto there are plenty of fields where the protocol designer would say "this value is nonconfidential" or "this value is not required to be kept secret" -- reasoning from the protocol's internal cryptographic security goals -- where publishing the value still has other adverse consequences. For instance, TLS session tickets per RFC 5077: "since the ticket is encrypted and the attacker does not know the secret key, a stolen ticket does not help an attacker resume a session".
But the protocol's internal security goals aren't always the only relevant security goals, and in the session tickets example, there is also a privacy sensitivity about disclosing them in some contexts because they can be used to show that a particular party was responsible for a particular TLS sessions (like if you were using Tor to access a web site but then posted the session tickets under your own name because RFC 5077 says that they don't need to be kept secret).
I think that's precisely what's happened here. If you read SSH protocol specs, they will say that public keys never need to be kept secret -- from the point of the SSH protocol's security goals. That's great, and it's a fair point. Users can still have other perfectly reasonable security reasons to request that people not publish them in particular circumstances!
I feel your argument relies on these actually existing -- so what are these reasons?
Yes, but nobody has shown any compelling reasons in relation to pubkeys used for github.
And even if there were some potential small benefit it would have also be weighted against the benefit of having the whole population of pubkeys available for security research.
The OP article clearly exposes problematic practices that might have otherwise gone unnoticed.
It's equivalent to uploading someones PGP key to a keyserver without his or her permission.
Public Keys are supposed to be public. It's OK not to know that, but blaming Github for doing crypto right is not really clever...
If you don't want your public key to be traced back to you, generate a new pair just for github.
So github is doing crypto right by unnecessarily exposing data that is _only_ relevant to a) the user and b) his personal access to his repos?
By this logic, why not make crypto even better and add something like github.com/user.address, github.com/user.mail or github.com/user.phone?
public keys are essentially opaque tokens that do nothing more than ensuring that a counterpart of a connection is whoever you think is associated with the public key. The key itself does not convey that information. It conveys no information at all beyond its cryptographic properties.
Turning a key into anything else (e.g. through re-use, publishing it elsewhere in association with other data) is not an intrinsic property of the key.
On the other hand personal data such as an address cannot be easily replaced like a key, immediately ties it to a person and does not provide any cryptographic properties at all.
TL;DR: pubkey is not private data, user.address is not crypto
You can send someone else’s public key to an old-style keyserver. Although you might think this would be a favor, it’s actually extremely rude. The public key owner might have reasons for not using a keyserver and might prefer to distribute his public key via some other method—or he might not want to publicize the key at all beyond a small group of people.
Never publicize someone else’s key for them!
Admittedly, it's a risk we should be aware of. But regardless of whether it's rude or not, it doesn't seem to be what people expect. What's worse though is that whether it's malicious or not; user trust is practically impossible to get back after it's gone.
Makes me want to do a parody webpage explaining how to setup PGP by just copy/pasting one
In my uneducated opinion, that seems like a really good way to judge whether something qualifies as worthy of a bug bounty etc.
> <snip> and then a few more minutes to transform those back into a SSH key that I could log into systems with.
Hardly 'kudos' for them; the API to list public keys is listed by GitHub as 'accessible by anyone' in the documentation, it would be difficult to construe what they did as 'unauthorized' because of that.
https://developer.github.com/v3/users/keys/#list-public-keys...
https://bitbucket.org/site/master/issue/4222/no-support-for-...
I can't remember where half of mine have been saved. I should really revoke everything and start again, as I use it for accessing my VPS too.
How do you revoke all keys on Ubuntu and OS X?
For a revoking mechanism to be possible you would need a trusted third party (like a certificate authority) to verify the keys for each and every connection you make.
Does this mean GitHub finally supports Ed25519?
Defense in depth recommends having multiple layers of security, such that a breach of a single layer doesn't constitute a full breach. There's no requirement (and in fact I'd argue there's no solid recommendation) for including obscurity as one or more of the layers.
If I didn't have my public key on GitHub, it's unlikely that even that could fall into an attacker's hands. Not that I would rely on that assumption, but it would reduce my attack surface.
I think that's more accurate if you replace "think" with "can actually practically demonstrate".
Now, of course the user can take some responsibility for not upgrading their key in 10 years, etc.
I don't see why it's, like, some moral obligation to invite factoring attacks just because of the name of the key and knee-jerk hatred for "obscurity."
Put another way, it makes sense to avoid pure obscurity when adding it takes extra work. In this case, GitHub is going out of their way to add theoretical weakness, but apparently we must do it, because security bible!
Edit: to be fair, there is the difference that GitHub has already added it and probably didn't have to write C code to do it. So maybe this feature should be requested for things like, say, cPanel, and users' $HOME/.ssh/authorized_keys should be world-readable by default. Still, maybe it's worth doing in OpenSSH so everyone can get the huge benefits of this currently only enjoyed by GitHub's users.
1. Duty of care - should never have accepted keys provably weak.
2. Poorly communicated that username.keys was available, thus many users may have thought their keys weren't at risk.
3. No countermeasures from crawlers mass collecting keys. (Not they they should even need to do this - they should just have done #1 in the first place!)
This isn't a game man, GitHub hosts a ton of the world's open source code and they're supposed to be experts in cryptography and security. Russian mobsters, NATO spooks, bitcoin drug cartels, and even high school script kiddies are all constantly trying shit and it impacts us all not just the people with weak keys. If python core gets backdoored I get backdoored, no matter how careful I am with the software I install.
1. Picking a small key is all on the user. It's like choosing the single letter 'a' as a password. If you want to do so why not?
2. The key you give to github is a "public" key. It is made to be public so this should be irrelevant.
3. There is 'almost' no known countermeasures against mass crawls of public keys. Look at the recent attacks: https://blog.hboeck.de/archives/872-About-the-supposed-facto...
What they could do: check against databases of public keys to see if your key is weakened by such attacks.
In response to your #1:
Picking a password is all on the user too. But magically GitHub is competent enough to stop users from picking the password "ilovecake". Most users of GitHub are not security professionals. Just like most people opening a bank account are not bank vault security professionals.
Original:
They are downvoting me because they love / work at GitHub or don't understand how critical software security is. If you think about the physical life equivalent here (say a bank leaving keys out in the open for safe deposit boxes) there is no way to rationalize it. But all of a sudden it's our favorite social coding startup we can't actually call them out on a huge security fuck up. If this were Microsoft we'd be laughing.
That is definitely a good thing, but github wouldn't be responsible if they didn't do that and people chose weak passwords.
> If you think about the physical life equivalent here (say a bank leaving keys out in the open for safe deposit boxes) there is no way to rationalize it
No, it would be like a bank not actively looking for deposit box keys that customers may have dropped.
btw, I 100% think github should protect users from weak keys, I'm just disagreeing that they could somehow be sued for it
I don't see any good reason to put everyone's public key out in the open. Is there any possible way that hiding the keys would hurt github's profits?
The entire point of PKI is that the public key is meant to be public. The impact on your security if a properly-created public key gets out is absolutely nil. I don't see any reason to hide them, save for an irrational belief that only comes from not knowing how the math works.
Edit: Elsewhere commenters say GitHub wouldn't have allowed this for a different policy reason, so this problem couldn't actually come to pass.
End of story. They should have blocked those keys. They didn't. The majority of the modern open source software movement is centred around a company that couldn't be bothered to lock down the cryptographic keys that protect millions of people from intrusion.
And when I point this out I get downvoted. Completely contrary to the HN guidelines of what deserves a downvote. If people disagree with me that it is gross negligence (which I still 100% view that it is) then they are more than able to voice that, but I'm not some new user shooting their mouth off or saying a dumb inane thing. I'm legitimately concerned about how seriously Github takes software security.
This is one of the reasons why should use different key pairs for different purposes.
I can't think of any reason that my SSH keys should be publicly avaiable. GitHub offers private repos so I can't understand why keys are all public by default.
What theory? I'm unaware of a current working theory that could be used to derive a private key from a public key of sufficient complexity.
This is textbook security through obscurity, and is considered ill-advised by the security community.
I think the "security through obscurity" principle ought to, if it doesn't already include this, say that added measures or core design principles should not be based on obscurity. This should not mean that all obscurity must be removed. In this case, GitHub have added anti-obscurity, and the defense is mainly dogmatic mis-application of the principle IMO.
I guess the response to that will be something about how they don't "deserve" protection because they used weak keys, and while I would resent that sentiment, I can't really argue against the idea.
To sum up, GitHub is doing something cryptographically unnecessary for this use case, that potentially harms confidentiality and anonymity for some users, and the arguments in favor seem to be: 1) A few users find it marginally useful, 2) It doesn't break the actual crypto if the users do it right, 3) Obscurity is taboo, 4) The name is "public key". I'll grant my position is weak, but so are those arguments. Their primary strength is dogma. Which, I don't know, maybe drilling crypto basics does have a net benefit even if they're not applicable to every situation.
This is wishful thinking. A Man In The Middle Attack would have worked on him.
This is not true.
Factually you haven't said anything I know to be wrong.
Just in case anyone is still reading, some rough analogies: Would you publish intermediate state data from a hashing or signing process? Would you publish your users' password hashes (even w/ scrypt and robust character set+length requirements)? Would you re-use Bitcoin addresses that have spent before?[1] Would you add a feature to an SSH server to return users' public keys to anyone on the internet? Would you have GPG auto-publish new keys to keyservers? I see these as not usually fatal, but not smart or necessary things, somewhat similar to this.
[1] One of the justifications for address rotation in Bitcoin is that once the address has spent, its 512-bit ECDSA public key is known, rather than just a RIPEMD160(SHA256()) hash of the public key. Absurd paranoia, lack of understanding crypto, or defense in depth?