Skip to main content

Beware what you click

Usually my (not too many :( ) posts are written for a technical audience (not too big :( ). This time, given the fact October is Cyber Security Month I will try to put some effort to try to explain how you can keep yourself away from annoyances. Well the rule of thumb is actually extremely simple and can be resumed with a simple sentence:

 Beware what you click

Let me repeate it: "beware what you click" :)
Just following this simple rule you can avoid 90% of scam/viruses and phishing attacks.
But lets do a step back. Assuming you know already what is a computer's virus let me explain what is a phishing attack. Phishing scam uses legitimate-looking websites to trick a victim into sharing their username, password or other  sensitive information. Pishers will design their sites to look exactly like e.g. the website of your mail provider, your bank, credit card issuer, or another financial institution. The hope is that you won't realize you are on the wrong site, and just punch your password like you normally would. Then, they use it to log into your accounts and e.g. transfer out your money.
So here some advice for you:
  • Look carefully at a website before giving any information (specially sensitive data)
  • Especially look out for slightly misspelled words
  • If something looks even a little fishy, delete the mail and close the site ASAP
  • Create bookmarks in your browser for commonly used sites (e.g. mail, bank, etc)
  • But overall

     Beware what you click

     
Non GEEK can STOP here :) Now let me show some example of phishing based on an open redirect I found on Google-Github OAuth integration :) This is a variant of the 'Lassie Come Home' OAuth attack I previously talked about.  In https://console.developers.google.com/project is possible to connect a project with Github. So far so good :) The problem is that the Google's OAuth client id registered in github (namely fde1c8c8834c1b0adcc8) has a registered redirect_uri that is too open (namely https://console.developers.google.com/). This is because the same OAuth client id is used for every Google project to connect with github. For example project APPS_A when connects to Github will end up having this request to the github authorization endpoint:

https://github.com/login/
oauth/authorize?client_id=fde1c8c8834c1b0adcc8&redirect_uri=https://console.developers.google.com/project/APPS_A&response_type=code&scope=repo&state=STATE

and APPS_B will have

https://github.com/login/oauth/authorize?client_id=fde1c8c8834c1b0adcc8&redirect_uri=https://console.developers.google.com/project/APPS_B&response_type=code&scope=repo&state=STATE

Note that the same client_id is used in both requests. This is possible because as said above the registered redirect uri is https://console.developers.google.com. Github validates only the start of the URI (as clearly stated here) and considers valid redirect uri if everything else is appended after the registered redirect uri. In our example the registered redirect uri is https://console.developers.google.com/ so github will consider valid https://console.developers.google.com/WHATEVER so in our case https://console.developers.google.com/project/APPS_A and https://console.developers.google.com/project/APPS_B are both valid and Google leverages happily this features :) Another thing to notice is that in Github once you authorize the application once the consent screen is not shown anymore namely the redirect will happen *without* human interaction.

So what an attacker needs to do is to upload an html file in the Google Cloud Storage Bucket and apply some open permission in order to be read by anyone (or by at least by the victim).
The html file will have a fixed uri of https://console.developers.google.com/m/cloudstorage/b/augmented-tract-3923rewrew233.appspot.com/o/aa/test.html. Notice that this is a valid redirect URI for fde1c8c8834c1b0adcc8 since it start with https://console.developers.google.com

So now  is possible to forge the initial OAuth call like this:

https://github.com/login/oauth/authorize?client_id=fde1c8c8834c1b0adcc8&redirect_uri=https://console.developers.google.com/m/cloudstorage/b/augmented-tract-3923rewrew233.appspot.com/o/aa/test.html&response_type=code&scope=repo&state=NtMfd5ccxz-a6GtwuqcQiv1L9Uc this will redirect to https://console.developers.google.com/m/cloudstorage/b/augmented-tract-3923rewrew233.appspot.com/o/aa/test.html?code=ccd04786b8113318c3d7&state=NtMfd5ccxz-a6GtwuqcQiv1L9Uc

Mind that test.html is controlled by the attacker.


To recap the attack looks like this:
  • the attacker forge an url like https://github.com/login/oauth/authorize?client_id=fde1c8c8834c1b0adcc8&redirect_uri=https://console.developers.google.com/m/cloudstorage/b/augmented-tract-3923rewrew233.appspot.com/o/aa/test.html&response_type=code&scope=repo&state=NtMfd5ccxz-a6GtwuqcQiv1L9U
  • the victim clicks the link
  • this will redirect to https://console.developers.google.com/m/cloudstorage/b/augmented-tract-3923rewrew233.appspot.com/o/aa/test.html?code=ccd04786b8113318c3d7&state=NtMfd5ccxz-a6GtwuqcQiv1L9Uc-
This is how a successfully phishing attack can be conducted (if the victim trusts Github or Google would be even simpler since the URL used in the attack are "familiar" domains for the victim).

As a consequence Google decided to tighten the redirect_uri in github (now is https://console.developers.google.com/project)

Final note, (unlikely for me) but good for Google:
otherwise I could as well steal the Authorization Code!!

Comments

Popular posts from this blog

Critical vulnerability in JSON Web Encryption (JWE) - RFC 7516

tl;dr if you are using go-jose, node-jose, jose2go, Nimbus JOSE+JWT or jose4j with ECDH-ES please update to the latest version. RFC 7516 aka JSON Web Encryption (JWE) hence many software libraries implementing this specification used to suffer from a classic Invalid Curve Attack. This would allow an attacker to completely recover the secret key of a party using JWE with Key Agreement with Elliptic Curve Diffie-Hellman Ephemeral Static (ECDH-ES), where the sender could extract receiver’s private key.

Premise
In this blog post I assume you are already knowledgeable about elliptic curves and their use in cryptography. If not Nick Sullivan's A (Relatively Easy To Understand) Primer on Elliptic Curve Cryptography or Andrea Corbellini's series Elliptic Curve Cryptography: finite fields and discrete logarithms are great starting points. Then if you further want to climb the elliptic learning curve including the related attacks you might also want to visit https://safecurves.cr.yp.to…

Slack SAML authentication bypass

tl;dr  I found a severe issue in the Slack's SAML implementation that allowed me to bypass the authentication. This has now been solved by Slack.
Introduction IMHO the rule #1 of any bug hunter (note I do not consider myself one of them since I do this really sporadically) is to have a good RSS feed list.  In the course of the last years I built a pretty decent one and I try to follow other security experts trying to "steal" some useful tricks. There are many experts in different fields of the security panorama and too many to quote them here (maybe another post). But one of the leading expert (that I follow) on SAML is by far Ioannis Kakavas. Indeed he was able in the last years to find serious vulnerability in the SAML implementation of Microsoft and Github. Usually I am more an "OAuth guy" but since both, SAML and OAuth, are nothing else that grandchildren of Kerberos learning SAML has been in my todo list for long time. The Github incident gave me the final…

CSRF in Facebook/Dropbox - "Mallory added a file using Dropbox"

tl;dr  Facebook Groups offers the option to upload files directly from the Dropbox account. This integration is done using the OAuth 2.0 protocol and suffered from a variant of the classic OAuth CSRF (defined by Egor Homakov as the the Most Common OAuth2 Vulnerability),  see video below:



Introduction  Facebook Groups offers the option to upload files directly from the Dropbox account:


This will allow to surf via browser the Dropbox account 


and post a specific file to the group.  This integration is done using a variant of the OAuth 2.0 protocol seen in this blog many many times. But once more, OAuth is an access delegation protocol standardized under the IETF umbrella. A typical OAuth flow would look like:
Usually the client initiates the OAuth flow in the following way:

then after that the resource owner has authorized the client the authorization server redirects the resource owner back to the client with an authorization code:
Then the OAuth dance continues....
Facebook/Dropbox i…