Page MenuHomePhabricator

Temporary accounts: Use anonymous user performer when creating a named account
Closed, ResolvedPublic

Description

Summary

Replace the temporary account perfomer with a new, anonymous user performer when creating a named account

Background

  • As discussed with Legal in T335508: Connect temporary and permanent account during signup in Special:CheckUser / Special:Investigate, it's important to avoid leaking the association between a temporary account and a permanent account. In the temporary account to permanent account creation workflow, it's easiest to avoid leaking the temporary account's identity in various code paths if we require the temporary account user to be logged-out before creating a permanent account.
  • Some options for this include:
    • Log the temporary account user out upon visiting Special:CreateAccount (and in API attempts)
    • Introduce a modal on clicks to "Create account", where "Proceed" does an API call to logout before redirecting to Special:CreateAccount
    • Swap out the temporary account performer in AuthManager::beginAccountCreation with a new anonymous user object

Acceptance criteria

  • The performer seen in AuthManager::beginAccountCreation is an anonymous user object

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change #1143146 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[mediawiki/core@master] [WIP] Log temporary account users out when creating accounts

https://gerrit.wikimedia.org/r/1143146

This assumes accounts are created via Special:CreateAccount. However, some apps may create accounts via API - it will be a breaking change if API behavior is changed.

This assumes accounts are created via Special:CreateAccount. However, some apps may create accounts via API.

Thanks :) the patch above also handles the API. We will probably also create subtasks for the Wikimedia iOS and Android apps.

kostajh renamed this task from Temporary accounts: Require temporary users to logout before creating permanent accounts to Temporary accounts: Use anonymous user performer when creating a named account.May 8 2025, 12:53 PM
kostajh updated the task description. (Show Details)

Change #1143146 merged by jenkins-bot:

[mediawiki/core@master] Use anonymous user when creating named account from temp account

https://gerrit.wikimedia.org/r/1143146

Change #1145455 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[mediawiki/core@wmf/1.45.0-wmf.1] Use anonymous user when creating named account from temp account

https://gerrit.wikimedia.org/r/1145455

Change #1145455 merged by jenkins-bot:

[mediawiki/core@wmf/1.45.0-wmf.1] Use anonymous user when creating named account from temp account

https://gerrit.wikimedia.org/r/1145455

Mentioned in SAL (#wikimedia-operations) [2025-05-14T07:06:52Z] <kharlan@deploy1003> Started scap sync-world: Backport for [[gerrit:1145455|Use anonymous user when creating named account from temp account (T393628)]]

Mentioned in SAL (#wikimedia-operations) [2025-05-14T07:11:35Z] <kharlan@deploy1003> kharlan: Backport for [[gerrit:1145455|Use anonymous user when creating named account from temp account (T393628)]] synced to the testservers (https://wikitech.wikimedia.org/wiki/Mwdebug)

Mentioned in SAL (#wikimedia-operations) [2025-05-14T07:26:44Z] <kharlan@deploy1003> Finished scap sync-world: Backport for [[gerrit:1145455|Use anonymous user when creating named account from temp account (T393628)]] (duration: 19m 51s)

Change #1152050 had a related patch set uploaded (by Dreamy Jazz; author: Kosta Harlan):

[mediawiki/core@REL1_44] Use anonymous user when creating named account from temp account

https://gerrit.wikimedia.org/r/1152050

Change #1152051 had a related patch set uploaded (by Dreamy Jazz; author: Kosta Harlan):

[mediawiki/core@REL1_43] Use anonymous user when creating named account from temp account

https://gerrit.wikimedia.org/r/1152051

Change #1152050 merged by jenkins-bot:

[mediawiki/core@REL1_44] Use anonymous user when creating named account from temp account

https://gerrit.wikimedia.org/r/1152050

Change #1152051 merged by jenkins-bot:

[mediawiki/core@REL1_43] Use anonymous user when creating named account from temp account

https://gerrit.wikimedia.org/r/1152051

@kostajh A couple of observations:

  • When a temp user creates a named account, CheckUser attributes this to the IP not the temp account. Is this OK?
  • When a temp user creates a named account via the API (sandbox), they have their session cookies cleared. On refresh, they are (sometimes) automatically logged in as the temporary user again but without a <wiki>_Token (so the session is lost when they close their browser). I see the below warning in the log:
[session] Session "[50]CentralAuthSessionProvider<+:19103:~2025-2596>3ho7t5cld6j2fsar03d2gb7il5cbb2i8": Metadata merge failed: [Exception MediaWiki\Session\MetadataMergeException( /var/www/html/w/includes/session/SessionProvider.php:260) Key "CentralAuthSource" changed]
#0 /var/www/html/w/includes/session/SessionManager.php(649): MediaWiki\Session\SessionProvider->mergeMetadata()
#1 /var/www/html/w/includes/session/SessionManager.php(511): MediaWiki\Session\SessionManager->loadSessionInfoFromStore()
#2 /var/www/html/w/includes/session/SessionManager.php(198): MediaWiki\Session\SessionManager->getSessionInfoForRequest()
#3 /var/www/html/w/includes/Request/WebRequest.php(870): MediaWiki\Session\SessionManager->getSessionForRequest()
#4 /var/www/html/w/includes/session/SessionManager.php(149): MediaWiki\Request\WebRequest->getSession()
#5 /var/www/html/w/includes/Setup.php(514): MediaWiki\Session\SessionManager::getGlobalSession()
#6 /var/www/html/w/includes/WebStart.php(86): require_once(string)
#7 /var/www/html/w/index.php(50): require(string)
#8 {main}
[session] Failed to load session, unpersisting
  • On a wikifarm (I am using SUL3), I create a temp account on one of my content wikis, then create an account on my central/login wiki. I am logged in as the new user on the login wiki but still as the temp user on the content wiki.

@kostajh A couple of observations:

  • When a temp user creates a named account, CheckUser attributes this to the IP not the temp account. Is this OK?

Yes, this is desired per T335508: Connect temporary and permanent account during signup in Special:CheckUser / Special:Investigate

  • When a temp user creates a named account via the API (sandbox), they have their session cookies cleared. On refresh, they are (sometimes) automatically logged in as the temporary user again but without a <wiki>_Token (so the session is lost when they close their browser). I see the below warning in the log:
[session] Session "[50]CentralAuthSessionProvider<+:19103:~2025-2596>3ho7t5cld6j2fsar03d2gb7il5cbb2i8": Metadata merge failed: [Exception MediaWiki\Session\MetadataMergeException( /var/www/html/w/includes/session/SessionProvider.php:260) Key "CentralAuthSource" changed]
#0 /var/www/html/w/includes/session/SessionManager.php(649): MediaWiki\Session\SessionProvider->mergeMetadata()
#1 /var/www/html/w/includes/session/SessionManager.php(511): MediaWiki\Session\SessionManager->loadSessionInfoFromStore()
#2 /var/www/html/w/includes/session/SessionManager.php(198): MediaWiki\Session\SessionManager->getSessionInfoForRequest()
#3 /var/www/html/w/includes/Request/WebRequest.php(870): MediaWiki\Session\SessionManager->getSessionForRequest()
#4 /var/www/html/w/includes/session/SessionManager.php(149): MediaWiki\Request\WebRequest->getSession()
#5 /var/www/html/w/includes/Setup.php(514): MediaWiki\Session\SessionManager::getGlobalSession()
#6 /var/www/html/w/includes/WebStart.php(86): require_once(string)
#7 /var/www/html/w/index.php(50): require(string)
#8 {main}
[session] Failed to load session, unpersisting

@Tgr @DAlangi_WMF does this sound like an issue that we need to fix?

  • On a wikifarm (I am using SUL3), I create a temp account on one of my content wikis, then create an account on my central/login wiki. I am logged in as the new user on the login wiki but still as the temp user on the content wiki.

@Tgr @DAlangi_WMF do you think we need to do anything about this, and if so, what should we do?

  • When a temp user creates a named account via the API (sandbox), they have their session cookies cleared. On refresh, they are (sometimes) automatically logged in as the temporary user again but without a <wiki>_Token (so the session is lost when they close their browser). I see the below warning in the log:
[session] Session "[50]CentralAuthSessionProvider<+:19103:~2025-2596>3ho7t5cld6j2fsar03d2gb7il5cbb2i8": Metadata merge failed: [Exception MediaWiki\Session\MetadataMergeException( /var/www/html/w/includes/session/SessionProvider.php:260) Key "CentralAuthSource" changed]
#0 /var/www/html/w/includes/session/SessionManager.php(649): MediaWiki\Session\SessionProvider->mergeMetadata()
#1 /var/www/html/w/includes/session/SessionManager.php(511): MediaWiki\Session\SessionManager->loadSessionInfoFromStore()
#2 /var/www/html/w/includes/session/SessionManager.php(198): MediaWiki\Session\SessionManager->getSessionInfoForRequest()
#3 /var/www/html/w/includes/Request/WebRequest.php(870): MediaWiki\Session\SessionManager->getSessionForRequest()
#4 /var/www/html/w/includes/session/SessionManager.php(149): MediaWiki\Request\WebRequest->getSession()
#5 /var/www/html/w/includes/Setup.php(514): MediaWiki\Session\SessionManager::getGlobalSession()
#6 /var/www/html/w/includes/WebStart.php(86): require_once(string)
#7 /var/www/html/w/index.php(50): require(string)
#8 {main}
[session] Failed to load session, unpersisting

@Tgr @DAlangi_WMF does this sound like an issue that we need to fix?

This issue sounds similar to T158365: Session "{session}": Metadata merge failed: {exception} (which is quite old), but we need to fix at some point, yes. But normally, when a temp account transitions to a named account, the named account should take over normally. I remember we fixed this in T384523: [BUG] Failure to login to pilot wiki after temp account creation. Also, testing locally, this works as expected (the named account takes over). @dom_walden, can you confirm that the failure only happens when the metadata exception is thrown?

  • On a wikifarm (I am using SUL3), I create a temp account on one of my content wikis, then create an account on my central/login wiki. I am logged in as the new user on the login wiki but still as the temp user on the content wiki.

@Tgr @DAlangi_WMF do you think we need to do anything about this, and if so, what should we do?

I think this is expected. @dom_walden, what happens when you click on the "Login" button on the content/local wiki? Your named account should take over the temporary one since you're already logged in centrally?

This issue sounds similar to T158365: Session "{session}": Metadata merge failed: {exception} (which is quite old), but we need to fix at some point, yes. But normally, when a temp account transitions to a named account, the named account should take over normally. I remember we fixed this in T384523: [BUG] Failure to login to pilot wiki after temp account creation. Also, testing locally, this works as expected (the named account takes over). @dom_walden, can you confirm that the failure only happens when the metadata exception is thrown?

I have tried to reproduce the failure many times and, so far, I have always seen the metadata exception.

I think this is expected. @dom_walden, what happens when you click on the "Login" button on the content/local wiki? Your named account should take over the temporary one since you're already logged in centrally?

The named account does take over in this case.

There is no way to update session cookies across domains, so we'll need to invalidate the temp user's sessions on signup.

The metadata merge error is weird, but hard to say more without knowing exactly when and where it happens and what CentralAuthSource changed from/to (that should be included in the PSR-3 log context). It results in clearing session cookies, so it's not really related to being logged in with the wrong account, at least not directly (I guess clearing the local session will result in an autologin, and if the central wiki has the wrong session, that will be spread to the local wiki).

invalidate the temp user's sessions on signup

This should just happen if a user account is successfully created (not "Log the temporary account user out upon visiting Special:CreateAccount" as described in task description). The temporary account and session should remain when:

  • user quitted Special:CreateAccount without creating an account
  • user do not load account creation form (due to block or rate limit)
  • user failed to create an account (due to block, rate limit, invalid username/password or abuse filter)

@kostajh, the "Acceptance Criteria" section was not updated yet. Is there anything to do there now that this is resolved? Can we check the box? :)

There is no way to update session cookies across domains, so we'll need to invalidate the temp user's sessions on signup.

Note that this wasn't done. I still think it's a good idea. Otherwise the user can end up being logged in with the new username on some domains and the temp username on others, and that's at a minimum confusing, and it's probably not too hard to accidentally reveal the association between the accounts in that scenario.

Change #1168224 had a related patch set uploaded (by Tchanders; author: Tchanders):

[mediawiki/core@master] Invalidate temp user's sessions when creating a permanent account

https://gerrit.wikimedia.org/r/1168224

Change #1168224 merged by jenkins-bot:

[mediawiki/core@master] Invalidate temp user's sessions when creating a permanent account

https://gerrit.wikimedia.org/r/1168224

Tchanders subscribed.

I think we can re-resolve this - the additional change was small and similar to what we've done elsewhere.