Last modified: 2013-10-14 12:24:14 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 T55379, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 53379 - unchecking "Always use a secure connection when logged in" leaves forceHTTPS cookie set
unchecking "Always use a secure connection when logged in" leaves forceHTTPS ...
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
User preferences (Other open bugs)
1.22.0
All All
: High major (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks: ssl
  Show dependency treegraph
 
Reported: 2013-08-26 22:28 UTC by spage
Modified: 2013-10-14 12:24 UTC (History)
10 users (show)

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


Attachments

Description spage 2013-08-26 22:28:06 UTC
$wgSecureLogin is enabled on test2 wiki, so my logins redirect to https.  The fix for bug 29898 is also on test2 wiki, so I have a preference "Always use a secure connection when logged in" which defaults to checked.

But if I uncheck this and save my preferences, I can't access the site over HTTP -- I still get redirected to https. It's very confusing. No matter what I do, accessing any page over HTTP redirects me to the https secure URL until I logout.

It's happening because my UserLogin sets $wgCookiePrefixforceHTTPS to true, and changing the preference does NOT clear this cookie. I have to logout, after logging back in (which redirects to secure page), I can then access other pages over http.

Changing the 'prefershttps' preference should clear the cookie, or the preference needs a warning/tooltip/explanation that "This change will only take effect after you log out and log back in."
Comment 1 spage 2013-08-26 22:34:55 UTC
The converse isn't the case: if I then visit my preferences page over insecure http and re-check the preference "Always use a secure connection when logged in", upon saving preferences I'm redirected to the secure site, and all my subsequent attempts to access over http are redirected (good!).  Even though I don't have the forceHTTPS cookie set, even though I didn't log out and back in.
Comment 2 Derk-Jan Hartman 2013-08-27 15:52:35 UTC
I ran into this as well when testing. really confusing.
Comment 3 Tyler Romeo 2013-08-27 16:07:29 UTC
The help message might be the way to go. Because the preference isn't the only thing that determines whether the user is put over HTTPS or not.
Comment 4 Chris Steipp 2013-08-27 17:15:27 UTC
(In reply to comment #0)

> It's happening because my UserLogin sets $wgCookiePrefixforceHTTPS to true,
> and
> changing the preference does NOT clear this cookie. I have to logout, after
> logging back in (which redirects to secure page), I can then access other
> pages
> over http.

Correct. Your cookies, and their security, are setup on login, not preference updates. So you would have to re-login to see the effect.

A help notice would probably be the best way to handle it. The alternative is to reset all the user's cookies on a preference update, which I don't think is something we want to do.

(In reply to comment #3)
> The help message might be the way to go. Because the preference isn't the
> only
> thing that determines whether the user is put over HTTPS or not.

This is also true. If the preference is unchecked, we'll always set your cookies insecure, but we will redirect back to https if you came from an https page when you clicked login. So yeah, I think a warning message is really the only way we can sanely manage this.
Comment 5 Gerrit Notification Bot 2013-08-28 18:00:27 UTC
Change 81531 had a related patch set uploaded by Chad:
Add help message to prefershttps

https://gerrit.wikimedia.org/r/81531
Comment 6 Seb35 2013-08-29 01:27:36 UTC
Although it is true the cookie is removed when log out, I tried many times and it is never removed (with Opera 12.16 and Firefox 20.0). By investigating I see when I log out from a wiki (here frwiki) that the forceHTTPS cookie has a Secure attribute:

  Set-Cookie: frwikiforceHTTPS=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; secure; httponly

I wonder if this secure attribute doesn’t prevent the user-agent to modify/delete the non-secure cookie; I quickly searched in the RFC 6265 (cookies) but didn’t find anything about the interactions between secure and non-secure cookies. If this bug really comes this fact, the User::clearCookie have to be changed to receive an argument to clear explicitely-unsecure cookies.

As a side fact, I see there are two forceHTTPS cookies when you connect to Wikipedia: one set by frwiki (domain fr.wikipedia.org) and one set by login.wikimedia.org (domain .wikipedia.org); I don’t know how this interacts with this bug.

Login from the specific wiki (here frwiki):
  Set-Cookie: frwikiforceHTTPS=true; expires=Sat, 28-Sep-2013 00:49:37 GMT; path=/; httponly
Continuation of the login, from login.wikimedia.org:
  Set-Cookie: frwikiforceHTTPS=1; expires=Sat, 28-Sep-2013 00:49:37 GMT; path=/; domain=.wikipedia.org; httponly
Comment 7 Gerrit Notification Bot 2013-08-29 01:47:06 UTC
Change 81614 had a related patch set uploaded by Seb35:
Set a non-secure attribute when clearing a cookie

https://gerrit.wikimedia.org/r/81614
Comment 8 Seb35 2013-08-29 02:05:27 UTC
I confirm experimentally that removing the Secure attribute to the forceHTTPS cookie correctly delete the cookie when log out (on Opera 12.16 and Firefox 20.0). A step to really confirm this is to dive into the source code of Firefox, or perhaps try to better examinate the RFC 6265.

(I should have tested it before submitting the gerrit patch, sorry, it’s the first gerrit patch I submit.)
Comment 9 Seb35 2013-08-29 14:08:43 UTC
I was mistaken, sorry, a non-secure cookie can be deleted by a corresponding secure cookie. I just tried again with Opera and Firefox and they are really deleted (I probably worked too late last night), as it seems to be confirmed by the function nsCookieService::GetCookieStringInternal [1] in Mozilla (I guess it’s this one, although not sure). Therefore my gerrit patch is not useful, apart if some browsers search their internal database with exactly the same value for the secure attribute.

The bug in Wikimedia environment stays but only because the .wikipedia.org cookie is not deleted (the local one is deleted). By the way I should have open a new bug since it is a bit different than the original description, I read too quickly the description, sorry. This specific bug is 53536.

[1] http://mxr.mozilla.org/mozilla-central/source/netwerk/cookie/nsCookieService.cpp
Comment 10 Chris Steipp 2013-08-29 15:52:20 UTC
Thanks for the research Seb35. In most browsers, cookies with the same name will overwrite each other, even with different security, but there could be some browsers that don't. If you see any that follow that behavior, we could add your patch in. Otherwise, I think I'll focus on getting bug 53536 fixed.
Comment 11 Gerrit Notification Bot 2013-08-29 22:27:19 UTC
Change 81614 abandoned by Seb35:
Set a non-secure attribute when clearing a cookie

Reason:
This change was integrated in the more general change I3c16ff92781e1a72346058ae3838d8fc47019d55

https://gerrit.wikimedia.org/r/81614
Comment 12 Bartosz Dziewoński 2013-09-01 09:06:50 UTC
Is this fixed and deployed now?
Comment 13 Tyler Romeo 2013-09-01 16:25:06 UTC
I don't know about deployed, but definitely fixed.
Comment 14 Dan Jacobson 2013-10-13 20:24:49 UTC
Please add a second preference:
[ ] Never use a secure connection (HTTPS) when logged in.
for those who wish totally the converse.
Comment 15 Andre Klapper 2013-10-14 09:20:37 UTC
(In reply to comment #14)
> Please add a second preference:

Please file separate requests as separate tickets (though I can imagine this request to be a WONTFIX as I'm not convinced how large the userbase would be for adding yet another preference.)
Comment 16 Dan Jacobson 2013-10-14 12:24:14 UTC
(In reply to comment #15)
Well Facebook gets this right with a single choice,
so once this is working right on Wikipedia (yet?) one will be enough...

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


Navigation
Links