Page MenuHomePhabricator

?safemode=1 doesn't appear to have any effect with $wgAllowSiteCSSOnRestrictedPages enabled
Closed, ResolvedPublicBUG REPORT

Description

On MW 1.39, appending safemode=1 doesn't appear to do anything, and doesn't function as it should. In practice, this should disable JS and CSS on the wiki, but it doesn't actually appear to do anything. I'm not entirely sure if this is something new in 1.39, or if it was present in 1.38, but it doesn't work in 1.39.

Event Timeline

Docs says:

- safemode: Only register modules that have ORIGIN_CORE as their origin.
  This disables ORIGIN_USER modules and mw.loader.store. (T185303, T145498)
  See also: OutputPage::disallowUserJs()

It does not disable all JS and CSS, it disables all user provided JS and CSS (for example scripts from user pages 'User:<User>/common.js', but also from mediawiki namespace like 'MediaWiki:Common.js' or Gadgets)
Scripts provide by mediawiki itself are still working.

Docs says:

- safemode: Only register modules that have ORIGIN_CORE as their origin.
  This disables ORIGIN_USER modules and mw.loader.store. (T185303, T145498)
  See also: OutputPage::disallowUserJs()

It does not disable all JS and CSS, it disables all user provided JS and CSS (for example scripts from user pages 'User:<User>/common.js', but also from mediawiki namespace like 'MediaWiki:Common.js' or Gadgets)
Scripts provide by mediawiki itself are still working.

It doesn't work, though, from what you're saying, Common.css should also not be loaded, correct? If correct, then my original comment is correct because Common.css is still loaded.

Docs says:

- safemode: Only register modules that have ORIGIN_CORE as their origin.
  This disables ORIGIN_USER modules and mw.loader.store. (T185303, T145498)
  See also: OutputPage::disallowUserJs()

It does not disable all JS and CSS, it disables all user provided JS and CSS (for example scripts from user pages 'User:<User>/common.js', but also from mediawiki namespace like 'MediaWiki:Common.js' or Gadgets)
Scripts provide by mediawiki itself are still working.

It doesn't work, though, from what you're saying, Common.css should also not be loaded, correct? If correct, then my original comment is correct because Common.css is still loaded.

Yes, it includes Common.css.
Works for me with the current master and the latest REL1_39 from git

Steps to reproduce:

  • Login as interface admin
  • Go to MediaWiki:Common.css and include the content: #firstHeading { background-color: orange; }
  • Go to Main Page and the heading should be orange
  • Load the Main Page with safemode=1 and the heading is no longer orange

Docs says:

- safemode: Only register modules that have ORIGIN_CORE as their origin.
  This disables ORIGIN_USER modules and mw.loader.store. (T185303, T145498)
  See also: OutputPage::disallowUserJs()

It does not disable all JS and CSS, it disables all user provided JS and CSS (for example scripts from user pages 'User:<User>/common.js', but also from mediawiki namespace like 'MediaWiki:Common.js' or Gadgets)
Scripts provide by mediawiki itself are still working.

It doesn't work, though, from what you're saying, Common.css should also not be loaded, correct? If correct, then my original comment is correct because Common.css is still loaded.

Yes, it includes Common.css.
Works for me with the current master and the latest REL1_39 from git

Steps to reproduce:

  • Login as interface admin
  • Go to MediaWiki:Common.css and include the content: #firstHeading { background-color: orange; }
  • Go to Main Page and the heading should be orange
  • Load the Main Page with safemode=1 and the heading is no longer orange

I'm also using the latest release and it isn't working? Following the above steps. This is also being reported over at Wiki.gg

Do you have $wgAllowSiteCSSOnRestrictedPages enabled? That allows Common.css to get through safemode.

Do you have $wgAllowSiteCSSOnRestrictedPages enabled? That allows Common.css to get through safemode.

Ah, I do, yes. Seems like an oversight? Or is that intentional?

Aklapper renamed this task from ?safemode=1 doesn't appear to have any effect to ?safemode=1 doesn't appear to have any effect with $wgAllowSiteCSSOnRestrictedPages enabled.Dec 19 2022, 8:36 PM

Do you have $wgAllowSiteCSSOnRestrictedPages enabled? That allows Common.css to get through safemode.

Ah, I do, yes. Seems like an oversight? Or is that intentional?

wgAllowSiteCSSOnRestrictedPages is false by default because while much less exploitable than JavaScript, there are numerous ways to exploit CSS as well. Depending on your wiki's risk profile, and depending and the kind of trust and skill placed in site admins that edit MediaWiki:Common.css you may choose to allow site-wide CSS on restricted pages. This configuration variable exists intentionally and specifically only to do one thing, to allow site-wide CSS on restricted pages (such as login and password-related special pages, and indeed page views with safemode=1).

Regardless of this configuration variable, however, MediaWiki always prevents restricted pages from loading user-specific CSS or JavaScript (e..g "User:Foo/common.css and js), and also prevents loading of side-wide JavaScript (e.g. "MediaWiki:Common.js").

I've updated the safemode docs at https://www.mediawiki.org/wiki/Manual:Parameters_to_index.php#User_preference_overriding accordingly.