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

OpenSSL Key Recovery Attack on DH small subgroups (CVE-2016-0701)

Usual Mandatory Disclaimer: IANAC (I am not a cryptographer) so I might likely end up writing a bunch of mistakes in this blog post... tl;dr The OpenSSL 1.0.2 releases suffer from a Key Recovery Attack on DH small subgroups . This issue got assigned CVE-2016-0701 with a severity of High and OpenSSL 1.0.2 users should upgrade to 1.0.2f. If an application is using DH configured with parameters based on primes that are not "safe" or not Lim-Lee (as the one in RFC 5114 ) and either Static DH ciphersuites are used or DHE ciphersuites with the default OpenSSL configuration (in particular SSL_OP_SINGLE_DH_USE is not set) then is vulnerable to this attack.  It is believed that many popular applications (e.g. Apache mod_ssl) do set the  SSL_OP_SINGLE_DH_USE option and would therefore not be at risk (for DHE ciphersuites), they still might be for Static DH ciphersuites. Introduction So if you are still here it means you wanna know more. And here is the thing. In my last bl...

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://s...

The Curious Case of WebCrypto Diffie-Hellman on Firefox - Small Subgroups Key Recovery Attack on DH

tl;dr Mozilla Firefox prior to version 72 suffers from Small Subgroups Key Recovery Attack on DH in the WebCrypto 's API. The Firefox's team fixed the issue r emoving completely support for DH over finite fields (that is not in the WebCrypto standard). If you find this interesting read further below. Premise In this blog post I assume you are already knowledgeable about Diffie-Hellman over finite fields and related attacks. If not I recommend to read any cryptography book that covers public key cryptography. Here is a really cool simple explanation by David Wong : I found a cooler way to explain Diffie-Hellman :D pic.twitter.com/DlPvGwZbto — David Wong (@cryptodavidw) January 4, 2020 If you want more details about Small Subgroups Key Recovery Attack on DH I covered some background in one of my previous post ( OpenSSL Key Recovery Attack on DH small subgroups (CVE-2016-0701) ). There is also an academic pape r where we examine the issue with some more rigors. ...