Page MenuHomePhabricator

Security Preview for shared login domain
Closed, ResolvedPublic

Description

Brief description

We are planning to update MediaWiki authentication so all interaction with the login and signup forms happens on a shared domain. (See T348388: SUL3: Use a dedicated domain for login and account creation for details.) Will file a separate request about that soon, but there is a subtask we are trying to make a decision on which I thought was worth its own preview request.

You can find more details in T363695: Create a Wikimedia login domain that can be served by any wiki but in a nutshell, Wikimedia wikis use a dedicated domain for central login cookies. Currently this is login.wikimedia.org, which is set up as a standalone wiki. We are tasked with changing production authentication workflows so that, instead, the central cookie domain (currently involved in login redirect chains), must be the same domain as where the user interacts with the login of signup form. Meanwhile, users expect the login forms to be tailored to the local wiki where they are logging in from (i.e. localisation, branding, and interface customisation). We are considering achieving that by creating a new domain that's used for central login cookies, but is not its own wiki. Instead, it would be serving the local wiki's login from where the user clicked the login link, at an alternate URL. E.g. https://sso.wikimedia.org/en.wikipedia.org/wiki/Special:Userlogin being re-interpreted by MediaWiki as a request to https://en.wikipedia.org/wiki/Special:Userlogin with minor config differences. This re-interpretation would happen in the MediaWiki configuration layer.

Primary Contacts

What Security Team services do you anticipate needing?

We'll probably need an application security review for SUL3 as a whole. I don't think the shared domain approach separately needs further feedback.

What is the 'go live' date for deployment of this project

Probably end of Q1 or beginning of Q2 (so between 3-6 months). We plan to create the Beta cluster version of the shared domain nowish, to see if this approach causes any unexpected problems.

Technology overview

This is somewhat analogous to how our m-dot domains today are an alternate URL that our routing normalises to the canonical version, for MediaWiki to respond to (Apache and MediaWiki PHP don't see the m-dot hostname).

  • At the Apache layer (ie. in operations/puppet), before the usual rewrite rules are applied, requets for the "sso" domain will rewrite away the first directory segment of the URL. E.g. /foo/w/index.php and /foo/wiki/X are rewritten to /w/index.php and /wiki/X respectively, so that we don't need to modify or duplicate other rewrite rules.
  • multiversion: The logic for identifying the site / language is extended to recognise sso.wikimedia.org, using the first directory segment to identify the wiki, instead of the host name.
  • wm-config: CommonSettings.php checks for the special host name and sets various configuration settings (e.g. $wgServer, $wgArticlePath, $wgScriptPath) accordingly.
  • Various CentralAuth hooks limit the functionality available via this domain (only the special pages and API endpoints that are necessary for login, no articles or other requests permitted) and normalize the login page so that most links (help pages, etc.) use full URLs with the wiki's canonical domain.

Security considerations

  • The main risk that we considered is using this special domain to access things that the attacker would otherwise not have access to, such as private wiki contents. This is prevented at multiple independent layers:
    • CommonSettings.php is hardcoded to exit when the special domain is used but the wiki is not using CentralAuth.
    • Functionality is limited only to public login- and signup-related special pages and API actions, which are public on our private wikis also.
    • When a wiki is accessed via this special domain, it uses its normal configuration settings (with some minor differences which should not be security-relevant), so even if the other defenses fail, an unauthorized user would not be able to do anything they can't directly do on the private wiki's domain.
  • There are several ways in which this approach preserves security weaknesses of the status quo (where the user could interact with the login page on any one wiki, and all wikis use the same session cookie value), which is a lost opportunity compared to the alternative implementation where we segregate all login processing to a single central wiki which is more locked down than normal wikis:
    • The special login domain is shared by all wikis, so an exploit (such as an XSS) on any one wiki could be used to access the shared cookies, if it can be triggered through the special domain. Note that, since the special domain is limited to authentication-related special pages, these naturally already disable all gadgets and other personal user scriptgs or site-wide JS customizations.
    • The set of extensions that are enabled and somehow reachable even on an authentication-related special page will differ from wiki to wiki and encompass all kinds of non-authentication-related things.
    • i18n messages used on the login page will continue to be community-editable, same as they are today.

Code

The patches for the proof-of-concept implementation can be found in T365162: Set up sso.wikimedia.beta.wmflabs.org with config-layer routing to other wikis.

Working test environment

Beta cluster, soon (T365162). The change is mainly in operations/mediawiki-config so not really testable locally.

Details

Author Affiliation
WMF Technology

Event Timeline

Does this need to be security protected?

sbassett changed the task status from Open to In Progress.Jul 3 2024, 5:12 PM
sbassett claimed this task.
sbassett triaged this task as Medium priority.
sbassett moved this task from Upcoming Quarter Planning Queue to In Progress on the secscrum board.

Does this need to be security protected?

I assumed I can't unprotect it since with security tasks that is the case, but apparently I can just edit the visibility, so I'll make it public. It certainly doesn't contain anything sensitive.

Tgr changed the visibility from "Custom Policy" to "Public (No Login Required)".Jul 9 2024, 8:43 AM
Tgr changed the edit policy from "Custom Policy" to "All Users".

The configuration is now live in the beta cluster - the domain is not used for anything yet, but it works.
Example of an allowed request: https://sso.wikimedia.beta.wmflabs.org/en.wikipedia.beta.wmflabs.org/wiki/Special:UserLogin
Example of a disallowed request: https://sso.wikimedia.beta.wmflabs.org/en.wikipedia.beta.wmflabs.org/wiki/Main_Page

Hey @Tgr - I'd like to set up an initial threat-modeling/concept-review session (or two) for this work with you and any other relevant folks, this quarter. Are there any other technical folks that you're aware of who would likely be helpful during or interested in participating in such exercises? Thanks.

Do you mean the shared login domain specifically or the SUL3 project in general? (I'll file another security preview request about T363699: Determine and implement SUL 3 login handshake mechanism in a day or two, once I have PoC code. I think these are the two particularly security-sensitive parts of the project, the rest of the work is less interesting.)

In general, @Krinkle might be interested as the principal engineer who is closest to the project. For the shared domain, I think it would make sense to also involve the SRE subteam which works with MediaWiki configuration (Service Ops, I think?). And maybe @daniel is interested since he did most of the work on the configuration loader, and conceptually I think configuration is a MediaWiki Interfaces Team thing (although on paper it's unowned).

The nominal owner of operations/mediawiki-config is RelEng but I don't think this is really relevant to them. @Reedy is marked as the maintainer.

Do you mean the shared login domain specifically or the SUL3 project in general? (I'll file another security preview request about T363699: Determine and implement SUL 3 login handshake mechanism in a day or two, once I have PoC code. I think these are the two particularly security-sensitive parts of the project, the rest of the work is less interesting.)

I mean the entire project. We can, of course, talk about any specific concerns - that would likely be the focus of any threat-modeling sessions anyways. Would all of this be ready for discussion in a couple of weeks or so? Or would more time be required? We're flexible on planning threat-modeling sessions, but generally would like most relevant work, features, etc. to be in a discussible state.

In general, @Krinkle might be interested as the principal engineer who is closest to the project. For the shared domain, I think it would make sense to also involve the SRE subteam which works with MediaWiki configuration (Service Ops, I think?). And maybe @daniel is interested since he did most of the work on the configuration loader, and conceptually I think configuration is a MediaWiki Interfaces Team thing (although on paper it's unowned).

Ok, I'll likely add @Krinkle and @daniel as (optional) participants to any threat-modeling sessions we schedule.

In general, our threat-modeling sessions are based upon STRIDE and open discussion. I'm happy to point anyone to various (internal) artifacts for some sessions that we've conducted in the past if that would be helpful.

Would all of this be ready for discussion in a couple of weeks or so?

Discussed elsewhere, but for the record, we are planning to have the code that's the most interesting from a security perspective in place by next week.

A somewhat oversimplified diagram of how the cookie exchange between domains works: https://prezi.com/p/euajtznrs59r/?present=1

A somewhat oversimplified diagram of how the cookie exchange between domains works: https://prezi.com/p/euajtznrs59r/?present=1

Ok, great. We can chat about this today during the threat-modeling exercise; though I'm not really seeing anything immediately concerning here, especially since this is intended as an improvement over SUL2. I've also pre-populated the threat-modeling template for SUL3 with some threats for the SSO domain/wiki (largely based upon comments I saw in Phabricator on various tasks), though it seems like most of those have been addressed within the initial beta deployment/config for the SSO domain/wiki, so we don't have to dwell on those. Other than that, I think the threat-modeling session will be an open forum to document and discuss any security concerns or potential issues with SUL3, so we have all of that information stored in an artifact somewhere.

Update: We had our first threat-modeling session on 2024-08-29. Notes:

  1. The working group produced an initial threat-modeling document
  2. @Tgr updated said document with various task and change set ideas to reflect the current status/completion of various mitigation efforts
  3. The Security-Team will further analyze and tidy up the threat-modeling document, if necessary
  4. The Security-Team will work with @Tgr et al to plan another round of threat-modeling to address remaining concerns and yet-to-be-discussed security features of SUL3

Update: We had our first threat-modeling session on 2024-08-29. Notes:

  1. The working group produced an initial threat-modeling document
  2. @Tgr updated said document with various task and change set ideas to reflect the current status/completion of various mitigation efforts
  3. The Security-Team will further analyze and tidy up the threat-modeling document, if necessary
  4. The Security-Team will work with @Tgr et al to plan another round of threat-modeling to address remaining concerns and yet-to-be-discussed security features of SUL3

@sbassett do we have another another round scheduled? Will this second round be the last piece of the security preview or we need to request and plan a full security review?

@sbassett do we have another another round scheduled? Will this second round be the last piece of the security preview or we need to request and plan a full security review?

I think we might need one more round, to discuss any lingering issues or concerns with the current architecture and what has been built at this time. I would defer to you and @Tgr about when the best time to do that might be. It's getting a little close to the end of the quarter here, but I'm happy to fit in another session if that can work with folks' schedules. But early next quarter would also work, if that makes more sense. Thanks.

@MSantos - I've tentatively booked a follow-up threat-modeling session for October 9th, 2024.

sbassett moved this task from In Progress to Our Part Is Done on the secscrum board.

Internal threat model worksheet: https://docs.google.com/document/d/1ULQEehjIvcl4_lLPU7MOsqbClhOk2xHQRvehVI7wj4g

I'm going to resolve this task for now and the Security-Team will await the creation of the SUL3 security review task.