Page MenuHomePhabricator

ChangeContentModel throws permission errors despite being sufficiently privileged
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Acquire interface administrator rights (which includes the ability to change the content model of CSS/JS pages)
  • Have another user create a CSS page in their userspace like User:SodiumDogFood/style.css
  • [If you have recently logged in, wait at least an hour to make sure you have to reauth]
  • Click on Change model (or manually navigate to Special:ChangeContentModel/NAME_OF_PAGE)

What happens?:

image.png (1,717×714 px, 129 KB)

What should have happened instead?:

The normal reauth flow, not a notice telling me I cannot do what I am about to do.

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

Event Timeline

The workaround that I found was to go to a different JS page, reauth there, and come back to change the content model.

neriah triaged this task as Unbreak Now! priority.Jul 6 2026, 6:09 AM
neriah added a project: Regression.
neriah subscribed.

Although there is a workaround (re-auth on another page), most users are unaware of it. Unbreak Now!

Looks like a side effect of Iae4182f. I think using RIGOR_FULL in checkPermissions() (so the form loads) and handling getReauthOperation() in onSubmit() (redirect to login when reauth is needed) might fix this.

Although there is a workaround (re-auth on another page), most users are unaware of it.

There's a reauth link right at the bottom of the error page.

There's a reauth link right at the bottom of the error page.

And when I use it, I'm redirected to the main page and have to navigate back to the special page again...

And when I use it, I'm redirected to the main page and have to navigate back to the special page again...

Hm yeah we should fix that. Filed as T431290: Reauthentication link in permission errors does not use returnto

I think the "You do not have permission" message is a bit misleading here since the user actually has the right but only needs to reauthenticate.

What actually needs to be handled in these cases is why, instead of displaying the second step for user, these errors are outright making you not able to do the action. This is not only an issue with 2FA-based checks, I encountered it today with just a regular captcha:

image.png (1,040×573 px, 36 KB)

The entire assumptions here need to change. MediaWiki should be able to handle the confirmation step without leaving the form. The current way of doing this for 2FA is misleading, since it ends up displaying a message that I have no permissions to edit the page when I do have them.

Maybe we could make PermissionError behave similar to UserNotLoggedIn when it's created with a PermissionStatus that only contains reauth-related errors, and then make sure everything that creates a PermissionError uses a status. We can't support redirect-on-submit behavior that way, but for special pages that might be fine.

Change #1307853 had a related patch set uploaded (by Neriah; author: Neriah):

[mediawiki/core@master] Prompt for reauthentication after submitting content model changes

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

I uploaded a patch for the specific case of Special:ChangeContentModel, following @HakanIST's original suggestion. On submit, if authorizeChange() returns a reauth operation, the user is redirected to reauthentication while preserving the form data, and after authentication the action continues automatically.
This also keeps the behavior consistent with editing site JS. In the future we should add a lock icon here, but I think that can be left as a todo.

Change #1307853 merged by jenkins-bot:

[mediawiki/core@master] Prompt for reauthentication after submitting content model changes

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

The issue in this task has been fixed. I created a subtask for the additional improvements that weren't necessary for a quick-fix of this task.