Page MenuHomePhabricator

CVE-2025-6597: MediaWiki should not consider autocreation as login for the purposes of security reauthentication
Closed, ResolvedPublicSecurity

Description

Certain pages must be used shortly after login; if that's not the case, the user is asked to reauthenticate. (See $wgReauthenticateTime.) This is to prevent an attacker from stealing a session cookie and then e.g. changing the password.

Since some of the "login" logic is shared between login and autocreation (specifically they both call AuthManager::setSessionDataForUser(), which is the method that sets the AuthManager:lastAuthTimestamp field in session data, which will be used for reauthentication checks), AuthManager ends up considering autocreation the same way as login. This means an attacker who got hold of a CentralAuth session cookie (valid on any wiki) can just visit a wiki where the user has no local account yet, get an account autocreated, and then change credentials or perform other sensitive operations.

See also T389010: CVE-2025-6926: SUL3 local login should not count for security reauthentication.

Event Timeline

Tgr changed Author Affiliation from N/A to WMF Technology.Mar 16 2025, 7:11 PM

Would the fix here be to just force re-auth within securitySensitiveOperationStatus() as the default behavior? e.g. don't check AuthManager:lastAuthId and AuthManager:lastAuthTimestamp?

That would lead to an infinite reauth loop I think. We just need to be more judicious of when we set lastAuthTimestamp. Should be an easy fix, will do it soon.

That would lead to an infinite reauth loop I think.

Yeah, I was implying there'd be some other state-based check here, just something that didn't rely upon last auth data. Anyhow, if you've got a fix in mind, great.

Yeah, I was implying there'd be some other state-based check here, just something that didn't rely upon last auth data.

I think the nice way to do it would be to

  • move the method from AuthManager to the session provider, so some session providers can decide to always or never support it, or force an OAuth token rerfesh if the access token is old, or whatever
  • CookieSessionProvider would mostly keep doing what it does, CentralAuthSessionProvider would do the same but in the central session
  • tell the session provider why the session is being changed to an authenticated one (probably on top of T394075: Investigate using different stores for different kinds of sessions) so it can differentiate between login / autologin / whatever

Not something to try in a security patch though.

LGTM, but would be nice to get another + review before we deploy this.

LGTM, but would be nice to get another + review before we deploy this.

Spent some time today testing this patch locally, @Tgr, let me know if my observation matches what you expect.

Before this patch, when an account is auto-created on a wiki [which previously didn't have that account], visiting the Special:ChangePassword page would just present the user with an option to change their password [the password change form], which is what we're trying to fix here.

With this patch applied, I did the following.

  • Set $wgReauthenticateTime = [ 'default' => 30 ]; [30 seconds]
  • Created an account on the shared domain say User:Foobar
  • Logout and login [on the shared domain] to spend some time for 30 sec to elapse.
  • Then go to a local wiki [say enwiki], clicked on the "Login" link. This will auto-create the central user on that wiki [which didn't exist before] then logs the user in.
  • I visit the Special:Preferences page on the local wiki and click on "Change password" button
  • I get redirected to the shared domain with a login form to re-authenticate.

I left a piece, also, I increased $wgReauthenticateTime = [ 'default' => 3600 ]; and I still had the same effect with this patch applied. By same effect, I mean I still had to re-authenticate form presented [login again] even though the time hasn't elapsed because the auto-creation wasn't considered for re-authentication.


Let me know if I'm missing something but I think it works as expected.

I think that's correct, although with the SUL3 setup it's tricky because the similar but distinct T389010: CVE-2025-6926: SUL3 local login should not count for security reauthentication might interfere. What I did is use cookie-based autocreation (just visit a local wiki with no local account, with the centralauth_* cookies set) and use a special page that doesn't redirect to the central domain (e.g. Special:BotPasswords).

Happy to deploy this Friday morning (would normally due Thursday after the late backport but it's a US holiday) and keep an eye on it, once everything's on 1.45.0-wmf.6. I didn't get the sense that it was more urgent than that?

Well, I took two months two fix it, so I can't exactly complain about urgency...
In terms of impact, the SUL3 task is the bigger one I think. It's not hard to hit that one accidentally; to exploit this one, you have to know what you are doing.

Well, I took two months two fix it, so I can't exactly complain about urgency...
In terms of impact, the SUL3 task is the bigger one I think. It's not hard to hit that one accidentally; to exploit this one, you have to know what you are doing.

Yeah, maybe let's plan to get this one and the ones from T389010 deployed during this coming Monday's security window.

sbassett changed the task status from Open to In Progress.Jun 23 2025, 9:35 PM
sbassett triaged this task as Medium priority.
sbassett moved this task from Security Patch To Deploy to Watching on the Security-Team board.

Deployed the above patch during today's security window (2025-06-23). I assume we want to track this for the core release.

sbassett added a parent task: Restricted Task.Jun 23 2025, 9:36 PM
Reedy renamed this task from MediaWiki should not consider autocreation as login for the purposes of security reauthentication to CVE-2025-6597: MediaWiki should not consider autocreation as login for the purposes of security reauthentication.Jun 24 2025, 11:28 PM

Change #1165075 had a related patch set uploaded (by Reedy; author: Gergő Tisza):

[mediawiki/core@REL1_43] SECURITY: Do not treat autocreation as login for reauthentication

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

Change #1165088 had a related patch set uploaded (by Reedy; author: Gergő Tisza):

[mediawiki/core@REL1_39] SECURITY: Do not treat autocreation as login for reauthentication

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

Change #1165101 had a related patch set uploaded (by Reedy; author: Gergő Tisza):

[mediawiki/core@REL1_44] SECURITY: Do not treat autocreation as login for reauthentication

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

Change #1165116 had a related patch set uploaded (by Reedy; author: Gergő Tisza):

[mediawiki/core@master] SECURITY: Do not treat autocreation as login for reauthentication

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

Change #1165088 merged by jenkins-bot:

[mediawiki/core@REL1_39] SECURITY: Do not treat autocreation as login for reauthentication

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

Change #1165135 had a related patch set uploaded (by Reedy; author: Gergő Tisza):

[mediawiki/core@REL1_42] SECURITY: Do not treat autocreation as login for reauthentication

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

Change #1165101 merged by jenkins-bot:

[mediawiki/core@REL1_44] SECURITY: Do not treat autocreation as login for reauthentication

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

Change #1165075 merged by jenkins-bot:

[mediawiki/core@REL1_43] SECURITY: Do not treat autocreation as login for reauthentication

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

Change #1165116 merged by jenkins-bot:

[mediawiki/core@master] SECURITY: Do not treat autocreation as login for reauthentication

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

Change #1165135 merged by jenkins-bot:

[mediawiki/core@REL1_42] SECURITY: Do not treat autocreation as login for reauthentication

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

sbassett changed the visibility from "Custom Policy" to "Public (No Login Required)".
sbassett changed the edit policy from "Custom Policy" to "All Users".
sbassett changed Risk Rating from N/A to Medium.