Update: If you see broken images like this: instead of a logo, the login detection won't work for this platforms because your browser is blocking requests to their domain. If you're using Firefox read the updates.

Without your consent most major web platforms leak whether you are logged in. This allows any website to detect on which platforms you're signed up. Since there are lots of platforms with specific demographics an attacker could reason about your personality, too.

(or maybe you've disabled third party cookies, or you are using something like Privacy Badger?)

Explanation

For most web platforms there's a way to abuse the login mechanism to detect whether a user is logged in to that service.

Although this vulnerability is well known for several years most companies won't fix it.

The exploit is pretty simple and actually easy to fix. Let's look at facebook.com to get an idea of how it works:

How does the login redirect mechanism work?

https://www.facebook.com/bookmarks/pages

At first we need to understand the login redirect mechanism. Say you're logged in and visit

Now if you open this URL in a private tab where you are not logged in, you will get redirected to the login screen with this URL:

https://www.facebook.com/login.php?next=https%3A%2F%2Fwww.facebook.com%2Fbookmarks%2Fpages

next

https%3A%2F%2Fwww.facebook.com%2Fbookmarks%2Fpages

Note theparameter in the URL:

That's the URL we came from and it is used to redirect us back there once we've logged in.

But if we enter the login URL in a browser tab where we are already logged in, we get redirected without getting prompted to login. Therefore this URL returns:

If logged in: the resource at the URL in the next parameter

parameter If logged out: the login screen

Bypass the Same Origin Policy

How does this URL help us? The Same Origin Policy prevents to read the results of this request from any other domain but https://facebook.com...

Well, the SOP is strict for HTML pages, but it allows to receive images from other origins! So if the resource in the next parameter would be an image we could read it from our website. It can't be any image though. Facebook checks if the URL in the next parameter starts with https://facebook.com . So we need to find an image on facebook.com. Should be easy, right? Actually it isn't, because facebook hosts almost all images on their CDN servers under the domain fbcdn.net . Though there is one image that you can find on almost every webserver: the good old favicon.ico !

This is how our login URL looks like with the favicon as next parameter:

https://www.facebook.com/login.php?next=https%3A%2F%2Fwww.facebook.com%2Ffavicon.ico

Logged in: returns the favicon image

Logged out: returns the HTML of the login page

It has a very interesting property

We can use this URL in an <img> tag in our website:

<img src="https://www.facebook.com/login.php?next=https%3A%2F%2Fwww.facebook.com%2Ffavicon.ico">

<img>

Logged in: receives the favicon image, will load it successfully, and the onLoad callback will be fired.

callback will be fired. Logged out: receives the HTML of the login screen, will fail to load it as an image, and the onError callback will be fired.

<img onload="alert('logged in to fb')" onerror="alert('not logged in to fb')" src="https://www.facebook.com/login.php?next=https%3A%2F%2Fwww.facebook.com%2Ffavicon.ico">

Other Platforms

Thistag's property:This leads to the final exploit:

This mechanism works for almost all major web platforms, because they all have a redirect parameter in their login endpoint and they need to host their favicon on their domain (bc of browser compatibility, and of the technical debt of the former lack of standards).