Page MenuHomePhabricator

CVE-2025-6590: Complete content leak of private wikis due to PasswordReset Wikitext injection in error message
Closed, ResolvedPublicSecurity

Description

https://office.wikimedia.org/wiki/Special:PasswordReset

Abuse the username field using {{:Homepage}} as the username.

Event Timeline

Dylsss triaged this task as Unbreak Now! priority.Apr 26 2025, 12:48 AM
Dylsss renamed this task from All private wiki leak due to PasswordReset Wikitext injection to Complete content leak of private wikis due to PasswordReset Wikitext injection in error message.Apr 26 2025, 12:54 AM
Dylsss added a project: Vuln-Infoleak.
Dylsss updated the task description. (Show Details)
Dylsss updated the task description. (Show Details)

I assume wfEscapeWikiText prevents the template expansion here? I think this warrants an emergency security deployment, I just want to make sure this won't break anything else. A simpler, temporary approach might be to just change htmlform-user-not-valid to "This isn't a valid username." or similar which wouldn't break anything, just downgrade the usefulness of the message. Or just adding some more validation/stripping around https://gerrit.wikimedia.org/g/mediawiki/core/+/94e485551e3c6e7f76a6c1c5483f6c04c598bd80/includes/user/PasswordReset.php#217.

A simpler, temporary approach might be to just change htmlform-user-not-valid to "This isn't a valid username." or similar which wouldn't break anything, just downgrade the usefulness of the message.

Off the top of my head, I don't think that is realistic. You would have to change it for every language (which would be a massive patch) otherwise you could just use uselang in the URL and use a different language I think?

Or just adding some more validation/stripping around https://gerrit.wikimedia.org/g/mediawiki/core/+/94e485551e3c6e7f76a6c1c5483f6c04c598bd80/includes/user/PasswordReset.php#217.

I don't think this code is ever reached because it hits the validation error on the username field within HTMLForm first.

Ok, I've got the patch staged on deployment to roll out to wmf.25. I'm going to deploy now and keep an eye on logstash errors just in case, but your patch looks fine.

sbassett added a parent task: Restricted Task.Apr 26 2025, 2:49 AM

Deployed to Wikimedia production. Logstash error rates fine. Officewiki seems fine now:

owiki.png (350×713 px, 36 KB)

Thanks for the quick report and patch.

sbassett changed the task status from Open to In Progress.Apr 26 2025, 2:53 AM
sbassett lowered the priority of this task from Unbreak Now! to Medium.

For historical context, there was some discussion about potential longer term solutions at T160266 but nothing really happened.

Does anyone have a problem if I deploy this patch to Miraheze too?

We have a fair number of private wikis and this isn't exactly a fun bug.

I only have access to the task via WMF NDA though so I'd like an explicit nod from someone.

The other alternative is disabling password resets on private wikis.

Does anyone have a problem if I deploy this patch to Miraheze too?

No problems with you all deploying, but please be extremely careful to avoid public disclosure of the issue and the patch at this time.

Does anyone have a problem if I deploy this patch to Miraheze too?

No problems with you all deploying, but please be extremely careful to avoid public disclosure of the issue and the patch at this time.

Thanks, I've gone ahead and deployed the patch and made it extremely clear that it can't be shared

I just want to make sure this won't break anything else.

It's a bugfix even aside from the security implications. Usernames cannot contain templates, but can contain some forms of wikitext markup (e.g. '''Foo''' is a valid username) so they should always be escaped when used in wikitext messages. Unfortunately our localization framework makes it very easy to miss.

I would say there is probably some argument for T297791, being able to decouple authn from the rest of mediawiki would prevent these types of vulnerabilities. This is the 3rd vulnerability where an attacker could dump all the content of our private wikis (T297322 and T297574 being the other two, which were exploitable since 2014), I don't think it can be guaranteed that another vulnerability like this won't come at some point in the future, code evolves and since private wiki configuration is not always taken into account it can be easy to create these types of vulnerabilities.

I am not sure what T160266 is about since I can't see it but it would nice to have some defense in depth against these types of issues.

I would say there is probably some argument for T297791, being able to decouple authn from the rest of mediawiki would prevent these types of vulnerabilities.

Or T391784 is the modern task but not sure how that looks for non-CentralAuth wikis

I am not sure there's much in common there. T297322 and T297574 are about missing permission checks. T297791/T391784 is about limiting the impact of SQL injection or remote code execution attacks (where the vulnerability is not specifically in the auth stack) by isolating authentication data. T160266 and this task is about using transclusion to exfiltrate private information. Fixing any one or two of those three groups wouldn't affect the rest.

I am thinking that once authentication is standalone, you could put the entire MediaWiki stack behind authentication. The goal being to completely remove it from the attack surface, making any MediaWiki-level vulnerabilities irrelevant for private wikis.

sbassett added a project: SecTeam-Processed.
sbassett changed Author Affiliation from N/A to Wikimedia Communities.
sbassett changed Risk Rating from N/A to High.
Reedy renamed this task from Complete content leak of private wikis due to PasswordReset Wikitext injection in error message to CVE-2025-6590: Complete content leak of private wikis due to PasswordReset Wikitext injection in error message.Jun 24 2025, 11:26 PM

Change #1165071 had a related patch set uploaded (by Reedy; author: Dylsss):

[mediawiki/core@REL1_43] SECURITY: Escape usernames in HTMLUserTextField validation errors

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

Change #1165084 had a related patch set uploaded (by Reedy; author: Dylsss):

[mediawiki/core@REL1_39] SECURITY: Escape usernames in HTMLUserTextField validation errors

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

Change #1165097 had a related patch set uploaded (by Reedy; author: Dylsss):

[mediawiki/core@REL1_44] SECURITY: Escape usernames in HTMLUserTextField validation errors

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

Change #1165084 merged by jenkins-bot:

[mediawiki/core@REL1_39] SECURITY: Escape usernames in HTMLUserTextField validation errors

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

Change #1165112 had a related patch set uploaded (by Reedy; author: Dylsss):

[mediawiki/core@master] SECURITY: Escape usernames in HTMLUserTextField validation errors

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

Change #1165097 merged by jenkins-bot:

[mediawiki/core@REL1_44] SECURITY: Escape usernames in HTMLUserTextField validation errors

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

Change #1165131 had a related patch set uploaded (by Reedy; author: Dylsss):

[mediawiki/core@REL1_42] SECURITY: Escape usernames in HTMLUserTextField validation errors

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

Change #1165112 merged by jenkins-bot:

[mediawiki/core@master] SECURITY: Escape usernames in HTMLUserTextField validation errors

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

Change #1165131 merged by jenkins-bot:

[mediawiki/core@REL1_42] SECURITY: Escape usernames in HTMLUserTextField validation errors

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

Change #1165071 merged by jenkins-bot:

[mediawiki/core@REL1_43] SECURITY: Escape usernames in HTMLUserTextField validation errors

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

SecurityPatchBot raised the priority of this task from Medium to Unbreak Now!.

Patch 02-T392746.patch is currently failing to apply for the most recent code in the mainline branch of core. This is blocking MediaWiki release 1.45.0-wmf.8(T392178)

If the patch needs to be rebased

To unblock the release, a new version of the patch can be placed at the right location in the deployment server with the following Scap command:

REVISED_PATCH=<path_to_revised_patch>
scap update-patch --message-body 'Rebase to solve merge conflicts with mainline code' /srv/patches/1.45.0-wmf.8/core/02-T392746.patch "$REVISED_PATCH"

If the patch has been made public

To unblock the release, the patch can be removed for the right version from the deployment server with the following Scap command:

scap remove-patch --message-body 'Remove patch already made public' /srv/patches/1.45.0-wmf.8/core/02-T392746.patch

(Note that if patches for the version don't exist yet, they will be created and the patch you specified removed)

Reedy subscribed.

Patch had a double space that was removed when submitting, hence the conflict.

Removed from deploy1002

sbassett lowered the priority of this task from Unbreak Now! to Low.Jul 8 2025, 8:31 PM
sbassett removed a project: Patch-For-Review.
sbassett changed the visibility from "Custom Policy" to "Public (No Login Required)".
sbassett changed the edit policy from "Custom Policy" to "All Users".