Last modified: 2014-10-20 00:17:10 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T72672, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 70672 - User specified CSS loads on Special:Preferences / Special:UserLogin
User specified CSS loads on Special:Preferences / Special:UserLogin
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
User preferences (Other open bugs)
unspecified
All All
: Unprioritized normal (vote)
: 1.24.0 release
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks: 68521
  Show dependency treegraph
 
Reported: 2014-09-10 18:37 UTC by Kunal Mehta (Legoktm)
Modified: 2014-10-20 00:17 UTC (History)
16 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Proposed patch (5.05 KB, patch)
2014-09-11 23:14 UTC, Krinkle
Details
Backport for REL1_23 (5.32 KB, patch)
2014-09-28 23:17 UTC, Markus Glaser
Details
Backport to REL1_22 (5.31 KB, patch)
2014-09-28 23:18 UTC, Markus Glaser
Details
Backport to REL1_19 (5.23 KB, patch)
2014-09-28 23:19 UTC, Markus Glaser
Details

Description Kunal Mehta (Legoktm) 2014-09-10 18:37:34 UTC
While investigating bug 68521 today, me and helder noticed that user-created CSS is loaded on Special:Preferences and Special:UserLogin. Both special pages call $out->disallowUserJs(), which only controls TYPE_SCRIPTS, not TYPE_STYLES or TYPE_COMBINED.

Is this a bug? Or is it safe for CSS to run on those pages?
Comment 1 Helder 2014-09-10 18:46:52 UTC
According to
https://bugzilla.wikimedia.org/show_bug.cgi?id=48931#c3
in IE in quirks mode you can also execute javascript using CSS:
.mw-special-Preferences {
 color:expression(importScript("..."));
}
Comment 2 Chris Steipp 2014-09-10 22:14:58 UTC
(In reply to Helder from comment #1)
> According to
> https://bugzilla.wikimedia.org/show_bug.cgi?id=48931#c3
> in IE in quirks mode you can also execute javascript using CSS:
> .mw-special-Preferences {
>  color:expression(importScript("..."));
> }

There are several ways to execute javascript from css. I would prefer we didn't allow it.
Comment 3 Krinkle 2014-09-11 22:38:36 UTC
Aside from IE's non-standard way of executing code, there's also unlimited ways of tricking the user into performing actions by manipulating the interface from CSS (which then results in the unintended execution of otherwise trusted *server-side* code).

When ResourceLoader was given an "origin" marker, this was designed to apply to a module. Not to scripts only.

I believe disallowUserJs predates ResourceLoader and might just generally have an unfortunate name (legacy aside), and should imho disallow userCss as well.
Comment 4 Krinkle 2014-09-11 23:14:53 UTC
Created attachment 16447 [details]
Proposed patch
Comment 5 Krinkle 2014-09-11 23:15:12 UTC
(In reply to Krinkle from comment #4)
> Created attachment 16447 [details]
> Proposed patch

Commit message
-------

OutputPage: Remove separation of css and js module allowance

* No longer segment module origin allowance by an "only=" content
  type. Both can be sensitive security-wise and there's no valid
  use case for allowing CSS anywhere you want to disallow JS. Both
  can significantly impact the user interface and cause unintended
  actions to be taken on the user's behalf, or desired actions to
  be made practically impossible.

* While at it, also remove the ability to set the module allowance
  directly. The reduceAllowedModuleOrigin method is all we need.
  I couldn't find usage or mention of setAllowedModules() in
  mediawiki-core nor in any other Wikimedia-hosted repository.

Bug: 70672
-------
Comment 6 Kunal Mehta (Legoktm) 2014-09-11 23:46:21 UTC
Tested, patch works fine so +1.

Nitpicks (not sure if these should be done as the original security patch or after it's public...):

* We should deprecate disallowUserJs and create a disallowUserModules
* OutputPage::filterModules and makeResourceLoaderLink shouldn't pass $type to getAllowedModules
Comment 7 Chris Steipp 2014-09-16 19:03:19 UTC
The patch is working for me, and fixes the issue. I think lego's comments should be done in a public patch, to keep the security one small.

I'll get this deployed.
Comment 8 Kunal Mehta (Legoktm) 2014-09-25 21:34:38 UTC
This bug not being public caused bug 71334 today.
Comment 9 Greg Grossmeier 2014-09-25 21:40:07 UTC
Given the above breakage, we should probably get these patches out before the next monthly maintenance release.
Comment 10 Markus Glaser 2014-09-28 18:36:07 UTC
Just to make sure: I assume this is deployed on the WMF servers already?
Comment 11 Markus Glaser 2014-09-28 23:17:55 UTC
Created attachment 16617 [details]
Backport for REL1_23

MediaWiki 1.23 is still running... I found not exact way to reproduce the exploit, so I can't really say if the patch fixes the issue. I'd be extremely happy if someone else could have a look at the patch and confirm it works. Also, I have packported the deprecation notices. Not sure if that makes sense. If not, I will provide another patch without these notices. Please advise.
Comment 12 Markus Glaser 2014-09-28 23:18:35 UTC
Created attachment 16618 [details]
Backport to REL1_22

MediaWiki 1.22 is still running... I found not exact way to reproduce the exploit, so I can't really say if the patch fixes the issue. I'd be extremely happy if someone else could have a look at the patch and confirm it works. Also, I have packported the deprecation notices. Not sure if that makes sense. If not, I will provide another patch without these notices. Please advise.
Comment 13 Markus Glaser 2014-09-28 23:19:13 UTC
Created attachment 16619 [details]
Backport to REL1_19

MediaWiki 1.19 is still running... I found not exact way to reproduce the exploit, so I can't really say if the patch fixes the issue. I'd be extremely happy if someone else could have a look at the patch and confirm it works. Also, I have packported the deprecation notices. Not sure if that makes sense. If not, I will provide another patch without these notices. Please advise.
Comment 14 Kunal Mehta (Legoktm) 2014-09-29 01:59:53 UTC
(In reply to Markus Glaser from comment #10)
> Just to make sure: I assume this is deployed on the WMF servers already?

Yes.

(In reply to Markus Glaser from comment #11)
> MediaWiki 1.23 is still running... I found not exact way to reproduce the
> exploit, so I can't really say if the patch fixes the issue. I'd be
> extremely happy if someone else could have a look at the patch and confirm
> it works. Also, I have packported the deprecation notices. Not sure if that
> makes sense. If not, I will provide another patch without these notices.
> Please advise.

To test it, add "body { background-color: red }" to your MediaWiki:Common.css. Note that your pages now have a red background. Visit Special:Preferences and/or Special:UserLogin. The red background should disappear if the patch is present and working.
Comment 15 Markus Glaser 2014-10-01 00:16:10 UTC
Giving early access to Wikia
Comment 16 Grunny 2014-10-01 14:26:57 UTC
(In reply to Markus Glaser from comment #13)
> Created attachment 16619 [details]
> Backport to REL1_19
> 
> MediaWiki 1.19 is still running... I found not exact way to reproduce the
> exploit, so I can't really say if the patch fixes the issue. I'd be
> extremely happy if someone else could have a look at the patch and confirm
> it works. Also, I have packported the deprecation notices. Not sure if that
> makes sense. If not, I will provide another patch without these notices.
> Please advise.

Tested 1.19 patch, and it's working fine.
Comment 17 Markus Glaser 2014-10-01 20:29:34 UTC
Tried Kunals test in all branches and it works.
Comment 18 Markus Glaser 2014-10-02 00:09:54 UTC
Thanks Grunny for your help!!
Comment 19 Markus Glaser 2014-10-02 00:11:26 UTC
Publishing this bug as the release is out.
Comment 20 Gerrit Notification Bot 2014-10-02 01:17:34 UTC
Change 164271 had a related patch set uploaded by Legoktm:
SECURITY: OutputPage: Remove separation of css and js module allowance

https://gerrit.wikimedia.org/r/164271
Comment 21 Gerrit Notification Bot 2014-10-02 01:30:24 UTC
Change 164271 merged by jenkins-bot:
SECURITY: OutputPage: Remove separation of css and js module allowance

https://gerrit.wikimedia.org/r/164271
Comment 22 timmrysk 2014-10-03 14:39:39 UTC
(In reply to Markus Glaser from comment #15)
> Giving early access to Wikia

What about those of us who are running giant platforms as well such as Gamepedia?
Comment 23 Alexia E. Smith 2014-10-03 14:42:29 UTC
It appears this change is also affecting custom skin CSS(Mediawiki:Vector.css) instead of only cusotm user CSS.  This prevents custom site styles, that are only editable by the site administrators, loaded through Mediawiki:Vector.css to not display when on those pages.  Unfortunately that ends up being a jarring experience for the end user.
Comment 24 Bawolff (Brian Wolff) 2014-10-04 14:29:13 UTC
FWIW, I don't think the security benefit (which is at best minimal) of this change is worth the inconvenience to users who do custom skinning by editing MediaWiki:Common.css (See also my email to wikitech-l https://lists.wikimedia.org/pipermail/wikitech-l/2014-October/078903.html )
Comment 25 [[kgh]] 2014-10-07 07:49:43 UTC
This is indeed a big problem for wikis which use on-wiki custom skinning. Besides this indeed rather the regular case than a rare one. Now with some days having passed I can report that people even thought their login was maliciously hijacked since this page now looks totally different than the rest of the wiki. While the actual security increased the felt security dramatically plunged. :( I utterly agree with Bawolff.
Comment 26 Marc Schiffres 2014-10-07 18:43:16 UTC
I'm in agreement with Alexia and Bawolff (and kgh). For sites that use that use massive custom changes to their skins, such as the background color or the sidebar, having all this not show up on Special:Preferences or Special:UserLogin really takes away more than the minimal security it adds. Given that, as Alexia said, only administrators can even edit these interface pages, it's only reasonable that they should affect the entire site. Using my own site as example: http://grisaiawiki.net/ where I changed all sorts of colors and styles through Common.css, I was a bit off-put when I noticed that my changes aren't showing up on a few pages. User-specific CSS and JS not showing up on these pages is fair, but site-wide interface edits should get through.
Comment 27 Chris Steipp 2014-10-07 22:21:40 UTC
I talked with Kunal about this yesterday. My perspective is that admin controlled css is probably the least likely place someone is going to inject something malicious. The user controlled css is the part that scares me the most.

I'd be ok with a config option to allow Common.css and the skin css files through. I'm not sure how much work that would be in resource loader.
Comment 28 Kunal Mehta (Legoktm) 2014-10-10 07:01:57 UTC
Bug 71621 is tracking the issue of site-wide styles not being loaded, and I've uploaded a patch for it.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links