Skip to main content

On (OAuth) token hijacks for fun and profit part #2 (Microsoft/xxx integration)

In a previous blogpost we have already analyzed a token hijack on one OAuth integration between some Microsoft and Google service and seen what went wrong.
Now it is time to see yet another integration between Microsoft and xxxx (unluckily I can't disclose the name of the other company due the fact the haven't still fixed a related issue...) and see some fallacy.
But before to focus on the attack we might need a bit of introduction.


HTTP referrer


An HTTP referrer (misspelled as referer in the spec) is a special HTTP header field that browsers (and http clients in general) attach when surfing from a page to another. In this way the new webpage can see where the request originated. One extra thing to point out is that as per section 15.1.3 (Encoding Sensitive Information in URI's) of HTTP RFC [RFC 2616]:

Clients SHOULD NOT include a Referer header field in a (non-secure) HTTP request if the referring page was transferred with a secure protocol.

This is summarized in the image below:


The issue


Microsoft (of course) offers some service that allows you to have your Office document displayed online (similar to Google docs). For Microsoft Word the address is https://word.office.live.com/ .
Now this service is also integrated with other partners and you can display document hosted to a partner website doing something like

https://word.office.live.com/wv/WordView.aspx?FBsrc=http%3A%2F%2PARTNER_WEBSITE%2Fattachments%2Fdoc_preview.php%3Fmid%3Dmid.1426701639299%253A78532202c0996b8097%26id%3D10152839561617017%26metadata&access_token=AQD2GswFGnDGl28A&title=sanso-test

The two things to note in the link above are (in bold):

  • The partner website address (http://PARTNER_WEBSITE)
  • The access_token contained in the URI (access_token=AQD2GswFGnDGl28A)
Anybody bearing this URI can access to a Word document uploaded to  PARTNER_WEBSITE via a Microsoft service https://word.office.live.com/

 

The bad part of this is that if the document contains a link and if the victim clicks on the link the above mentioned referrer will leak the access token.

 

 The attack


The attack might look like this:

- The attacker craft a special Word document containing a link to a website he owns (MUST be https though)
- The attacker upload the file to the PARTNER_WEBSITE 
- The attacker shares this document with the victim
- The attacker waits for the victim to access the document and click to the link

And yep the Referrer will contain the victim's access token leaking it.

You might argue that the attacker would not gain anything by stealing this access token since it would allow to have access to a resource the attacker can already see. This indeed might be put in the bucket of the privacy issue rather than security vulnerability. From the other hand it is really matter of how good is the implementation at the PARTNER WEBSITE and how granular is the hijacked's access token.
In any case Microsoft fixed promptly the issue (fixing the referrer leakage) and rewarded me with a bounty (thanks MSFT).

<snip>
//SHAMELESS SELF ADVERTISEMENT
If you like OAuth 2.0 and/or you want to know more about it here you can find a book on OAuth that Justin Richer and myself have been writing on the subject.
https://www.manning.com/books/oauth-2-in-action

</snip>

 

The bonus


While looking at this Microsoft endpoint I also found a stored XSS vulnerability (now also fixed :)) and Microsoft rewarded me as well for it (thanks MSFT)




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.