37

When you're logged in to a Stack Exchange account, it's possible to add and remove logins (associated OpenID/OAuth accounts) without performing any form of reauthentication.

This is not a full vulnerability in itself, but it provides an extremely easy way for an attacker who's found a temporary XSS vulnerability to turn that into a permanent account hijack. An XSS exploit on its own may only provide a minute of indirect access to a user's account. But with this login configuration, the attacker could use that minute to automatically:

  1. Add a new attacker-controlled login to the account. For example:

    • The XSS JavaScript would generate a random identifier, and use that to construct a login URL of the form http://hacker.example/openid/1234567.
    • The hacker.example server would automatically authenticate the first OpenID login request made with a given identifier, allowing it to be added to the account without user interaction. All subsequent login attempts would be automatically rejected for the user.
    • The hacker.example server would notify the operator with the account name and the generated identifier, and would allow them to login to it.
  2. Remove all existing logins from the account.

  3. Log the user out of their account, with no way to get back in.

If this exploit were used to hijack moderator and staff accounts it could makes it more difficult to quickly respond to an attack, creating a greater opportunity for extended abuse.

This is a broader instance of the same fundamental vulnerability which was previously-reported as Can we fix the security hole in the password change dialog and ask for a user's current password?. That instance is a little more straightforward to fix: just ask for the password again when changing it. However, safe reauthentication with OpenID/OAuth logins is more complicated. Most users' OpenID providers will be configured to automatically re-authenticate upon request, so there would be minimal security gain from requesting that.

Instead or as well, my suggestion is that for users that have a verified email address, require an emailed confirmation link to be clicked before committing any login changes.


I'm not a real security expert, but I've just found that fellow Stack Overflow user Troy Hunt, who is, previously described this vulnerability in his 2012 blog post Is Stack Overflow Secure? Kind of...:

If an attacker can add additional login accounts then they can create a persistent mechanism to get back into that Stack Overflow account at any time without needing to hijack the session. Now of course the victim can always go into their account settings and identify the presence of the new login, but it’s a question of how much damage is done before then.

How would an attacker mitigate the risk of having their newly added account removed? Just remove the victim’s original account(s) instead.

[...]

Finally, this is also a lesson for those considering using third party authentication providers. Yes, it’s great that you can farm off this work to someone who has a solid implementation, but you still have responsibility for securing the authenticated session on your site. If you choose not to, be aware of the risks because certainly we’ve seen them exploited before.

  • 12
    Note to potential naysayers: this is responsible disclosure since the linked question was asked a year ago. – Deer Hunter Mar 14 '16 at 19:47
  • 12
    "I'm not a real security expert" says one of the folks on the Security Hall of Fame. – hichris123 Mar 14 '16 at 22:41
  • 2
    This is still open, still no attention? you've gotta be absolutely damn joking – cat Jul 16 '16 at 16:54
  • 6
    This has been lingering so long @JeremyBanks got hired in the interim and can now fix it himself! – Tim Stone Nov 22 '16 at 22:40

You must log in to answer this question.

Browse other questions tagged .