SSH Key Audit on Github (required)
github.com
github.com
I was always very afraid of XSS attacks (I know - there shouldn't be any - but there could and were, though not for this) that would add another key, so I always hoped they would add that additional bit of protection.
As such: Another huge thanks to @homakov for forcing the issue.
But ever since that XSS vulnerability was shown maybe a year ago, I was scared that there could be another one of them as they are very, very easy to miss, especially when you have to rely on filtering instead of escaping.
Github has to because you can freely use HTML in Markdown, which is the main markup language on github.
So there we are: Relying on filtering out bad stuff from user content, instead of blindly escaping it, at least one XSS vulnerability already happened and the public key interface still allows adding keys without confirming the password.
It would really suck to be hit by a XSS attack that silently adds a key to my account, not only giving the attacker the possibility to impersonate me in commits, but, even worse, giving access to my private repositories.
Regardless of the fix for the problem on Sunday, I have always hoped Github would add the check for the password. Not to mitigate the mass-assignment problem, but to prevent a possible XSS attack from being used to deal much worse damage.
I see this package of changes that we see now happening at Github as a direct result of the Sunday hack, so while we got the mass-assignment fix (of course that had to be fixed), we also finally got the password recheck which we likely would not have gotten without the hack.
Hence my "thank you" to @homakov. Not just for uncovering the mass-assignment thing (which is a simple code fix), but also for forcing a change of policy (with negative usability repercussions and thus probably not universally accepted between github internals) elsewhere.
A non security theatre approach would be to keep track of all the add/update/remove of the keys in an append only log and on a regular basis do reconciliation and check that what you have in practice is what you have from the logs. This is intern to the system, you do not show it, this is real added security/control.
SaltwaterC 5 hours ago | link [dead]
The API token is still there, in the "plain": https://github.com/settings/admin
Fetching it via XSS should be fairly trivial. Via a simple script in that page is straight forward. Still have to see if I can get it via XHR :).
`ssh-keygen -lf ~/.ssh/id_rsa.pub`
`ssh-keygen -lf ~/.ssh/*.pub`
Yep, or use a non-default key name.
I'd expect such users to have just enough familiarity with ssh keys to know how to check them (though I could be wrong).
Edit: Also, GitHub's setup guide explicitly leads to rsa keys so anyone using dsa keys consciously made that choice http://help.github.com/mac-set-up-git/
Not giving instructions on the page on how to verify the info was weak. Github people, if you're reading this, please update that page.
It's a shame that hasn't carried through to the key audit page but there is (now) a link on how to verify keys (http://help.github.com/verify-ssh-redirect)
Most users will not have many keys (probably just one), and will be alerted if they see more.
I bet a lot of people would have verified their keys with instructions but didn't bother without.
The Linux instructions were
ls ~/.ssh/*.pub | xargs -L 1 ssh-keygen -l -f
I'll be honest - I didn't understand what those MAC address-type fingerprints were, and I accepted each key. Their email made me trustful, saying that probably no account was affected. I do feel bad saying this in public, but it is what I did when there was not more information immediately available to me.
for f in ~/.ssh/*.pub; do ssh-keygen -lf $f; done A security vulnerability was recently discovered that made it possible
for an attacker to add new SSH keys to arbitrary GitHub user accounts.
This would have provided an attacker with clone/pull access to
repositories with read permissions, and clone/pull/push access to
repositories with write permissions. As of 5:53 PM UTC on Sunday,
March 4th the vulnerability no longer exists.
While no known malicious activity has been reported, we are taking
additional precautions by forcing an audit of all existing SSH keys.
# Required Action
Since you have one or more SSH keys associated with your GitHub
account you must visit https://github.com/settings/ssh/audit to
approve each valid SSH key.
Until you have approved your SSH keys, you will be unable to
clone/pull/push your repositories over SSH.
# Status
We take security seriously and recognize this never should have
happened. In addition to a full code audit, we have taken the
following measures to enhance the security of your account:
- We are forcing an audit of all existing SSH keys
- Adding a new SSH key will now prompt for your password
- We will now email you any time a new SSH key is added to your
account
- You now have access to a log of account changes in your Account
Settings page
Sincerely, The GitHub Team
--- https://github.com support@github.comPresumably someone could have added a key, done evil, then removed the key. Evil includes all sorts of interesting things, like checking in code under the name of an existing contributor. This could potentially be really subtle and would be difficult to find in an audit later.
(Remember the stink over OpenBSD potentially having backdoors in the IPsec stack, revealed in late 2010? http://blogs.csoonline.com/1296/an_fbi_backdoor_in_openbsd)
Such an attack is unlikely, yes, but still possible.
Only modifying (existing) history will cause git to complain.
The issue is that I've had lots of ssh keys, and might not have my fingerprints for all of them. If I see a bad fingerprint, it's entirely probable it's just an old key of mine from an old laptop, cellphone, script, or whatever, and NOT an attacker's key.
But, in light of this attack which you revealed, now any account which contains keys which aren't 100% accountable could have been compromised by an attacker. (in fairness, someone who stole the github user password could have done the same thing too, but that's an obvious attack route)
Key management is such a pain!
ERROR: Hi andrewjshults, it's GitHub. We're doing an SSH key audit. Please visit https://github.com/settings/ssh/audit/<removed>; to approve this key so we know it's safe. Fingerprint: <removed> fatal: The remote end hung up unexpectedly
A little weird to see when you're doing a push but good that they put it in there. Their email got flagged as bulk in gmail so until I saw this I didn't know they were doing the audit.
I think this was handled very badly. This broke alot of automated jobs for many people. The email actually arrived after some of our automated jobs had stopped running. There should have been an advanced warning that such an audit would take place. I'm glad we had monitoring on our automations, but many people won't have those and might still be unaware that they are not running until they authorize their keys.
Edit: github send out an email with a link to the ssh audit page; that's the email to which I refer
(Because of the offline nature of most git actions and different habits on pushing/pulling, it's probably hard to otherwise estimate how much a user cares about their github.)
The amount of time between someone getting an email from github and re-activating their account is probably the best metric github will ever have on users' attachment to their accounts.
So the fact that they're sending out this E-Mail tells us that they either don't keep logs on requests + POST contents, or that they haven't had the time or inclination to analyze this data if they have it.
Every person that got this email now feels more secure about Github. They audited their own private keys. They were reminded that they can remove keys at will. And they know Github has improved its code and given users more power (email alerts, etc) to be in control of content.
No.
Github is primarily a B2B company. They're not making their big bucks off of individuals.
Businesses understand that problems arise. What they want to see is immediate action taken to rectify the problems.
Business 101. Even if the problem can be easily fixed by flipping a switch on your end that the customer never has to know about, always show the client "you did something to fix the problem". This is an in-your-face-we-are-taking-charge action. Even though it is completely unnecessary from a security standpoint, it is necessary from a business one.
They get it.
Was this Rails-related and what was it?
This script is very useful when doing this audit, because you can turn your .ssh/authorized_keys file into a list of key names and fingerprints to check against what github is showing you.
Anyway it is pretty moot at this point since I have long ago forgotten my password and changing the orgion to somebody else is pretty easy.
That said, can anybody recommend alternatives? I know Bitbucket and they seem pretty great, especially as they allow private repositories, but it seems the consensus here doesn't like them for some reason?
I'm a Mercurial guy, but they do git too.
People update public keys very rarely. I would even say NEVER.
Just make an sql against your table to see what are the most possibly are malicious keys.
(i see no reason to update timestamps doing 'the trick'. I believe attackers didn't)
That being said, we don't have the resources to deploy a more secure alternative without hamstringing our development capabilities (e.g. no internet connectivity).
Why isn't Github Enterprise an option for you? Too expensive? (plus of course you have to run it; if you don't have a good VPN or premises network, sysadmin resources to run it, etc., it's entirely possible a self-hosted thing could be less secure than a SaaS solution)
(The irony of my running a cloud tech startup and not trusting "the cloud" for our source control, email, file storage, compute, ... is not lost on me. It definitely adds costs, but I think this is an appropriate level of paranoia. The providers of business services need to provide convincing arguments why their services are secure enough to use, at least for b2b.)
i guess that's the precise moment when I should feel too much paranoid.
In any other business, the result of a similar mail would be an overloaded helpdesk, a significant reputation hit and a massive bucketload of competitor FUD.
also, if we go back few years ago this way would be a bit secure to handle keys @key.body = params.. @key.title = params.. I am sure update_attributes is good choice when you got 5+ fields and update database scheme pretty frequently. Just my 2 cents