Last modified: 2012-04-16 09:15:56 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T27793, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 25793 - Security problem: API allows to hijack sessionid
Security problem: API allows to hijack sessionid
Status: RESOLVED INVALID
Product: MediaWiki
Classification: Unclassified
API (Other open bugs)
unspecified
All All
: Normal major (vote)
: ---
Assigned To: Roan Kattouw
: patch
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-11-05 11:24 UTC by Marooned
Modified: 2012-04-16 09:15 UTC (History)
6 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
patch fixes mentioned issue (374 bytes, patch)
2010-11-05 11:24 UTC, Marooned
Details

Description Marooned 2010-11-05 11:24:53 UTC
Created attachment 7791 [details]
patch fixes mentioned issue

If you make a post to api.php with something like "action=login&lgname=TestUser&lgpassword=gotcha" the api responds with a NeedToken error, inside the error message the current session is included... so you can trick the api into telling you what the sessionid is to bypass httponly and get access to the user's login session.

On wiki farm (like Wikia) an evil admin could alter common.js to run this POST request via AJAX for every logged in user that enters his wiki - having sessions he would be able to log in as any visitor of his wiki by creating proper cookie.

Simple patch attached - for case LoginForm::NEED_TOKEN do not return sessionid.
Comment 1 Roan Kattouw 2010-11-05 11:44:01 UTC
All output of session IDs removed in r76077. I contemplated other ways of doing this, but none of them were secure.

The session ID was output to help clients that couldn't read cookies properly, but I'm afraid we're having to drop support for those now.
Comment 2 Roan Kattouw 2010-11-05 11:44:50 UTC
And thanks for reporting this!
Comment 3 Roan Kattouw 2010-11-05 11:57:33 UTC
Hmm, on second thought, this isn't a security issue at all. Reverted r76077 in r76080.

The only way an attacker can read the echoed session ID is if they can request it using JS running on the same domain (evil admin scenario, like you said). Cross-domain, it won't work. And if the attacker can run JS on the same domain, they can do much worse things already (e.g. bypass the CSRF safeguards and edit things as you), most notably access our cookies directly without needing the API to echo them back at them.
Comment 4 Roan Kattouw 2010-11-05 11:58:36 UTC
CC Tim Starling, want him to look at this in case I'm missing something.
Comment 5 Marooned 2010-11-05 12:08:27 UTC
This cookie is httponly so using document.cookie won't allow you to get it. The API call makes it possible.
CSRF allows evil admin to run unprotected actions - such actions should be fixed (by require token for example).

The bug mentioned here allows you not only to run unprotected action but take over the whole account and fixing it sounds reasonably.
Comment 6 Roan Kattouw 2010-11-05 12:21:44 UTC
(In reply to comment #5)
> This cookie is httponly so using document.cookie won't allow you to get it.
You're right about that, my mistake.

> The
> API call makes it possible.
Yes, but it doesn't matter much, see below.

> CSRF allows evil admin to run unprotected actions - such actions should be
> fixed (by require token for example).
> 
Yes, and we do require tokens. Tokens prevent CROSS-site scripting, but they can't protect against SAME-site scripting. Once the attacker has JS running on the same site, they can edit as you, create/move/delete pages at you, etc., etc., and we can't protect against that. So in practice, they've already taken over your account, and they can take it over for real by changing your e-mail address, using the "I forgot my password" feature to reset the password, then logging you out.

> The bug mentioned here allows you not only to run unprotected action but take
> over the whole account and fixing it sounds reasonably.
Stealing someone's cookies does allow you to take over their account, but once you're running JS from the same domain you can already do the same thing without needing the cookie data.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links