Last modified: 2014-09-12 09:19:20 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 T37820, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 35820 - [CSS] Some CSS stripped by MediaWiki parser CSS sanitizer
[CSS] Some CSS stripped by MediaWiki parser CSS sanitizer
Status: NEW
Product: MediaWiki extensions
Classification: Unclassified
CSS (Other open bugs)
unspecified
All All
: Normal enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-04-08 21:49 UTC by badon
Modified: 2014-09-12 09:19 UTC (History)
10 users (show)

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


Attachments

Description badon 2012-04-08 21:49:42 UTC
I have been unable to get background-image:url( someURL ) to work with this extension, like below:

{{#css:
	/*
		This code requires the CSS extension (previously used NewPageCSS)
		http://www.mediawiki.org/wiki/Extension:CSS
	*/

	.someClass { background-image:url(http://www.somedomain.com/w/images/0/06/someimage.png); }
}}

I believe it is due to Sanitizer::checkCss() as described by Brion here:

http://www.gossamer-threads.com/lists/wiki/mediawiki/233179

The CSS that gets sanitized by the parser is getting stripped out of the CSS extension too. 

However, the usual /* insecure input */ error message appears in the <head> of the page source, like this:

<style type="text/css">
/*<![CDATA[*/
/* insecure input */
/*]]>*/
</style>

The only way to get around this problem is to put the CSS in MediaWiki:Common.css.

There are good reasons for the parser to strip some CSS out, but in addition to documenting this issue (which this bug does, and I'll do in the extension docs in a moment), it should be configurable whether the CSS extension lets the parser sanitize, for example, when used on private wikis.
Comment 1 Quim Gil 2013-03-25 02:40:33 UTC
There is a proposal to improve Extension:CSS at

http://www.mediawiki.org/wiki/Mentorship_programs/Possible_projects#Improve_Extension:CSS

Pasting the part related with security to get more feedback:

"The CSS extension relies on basic blacklisting functionality in MediaWiki core to prevent XSS. It would be great if a proper CSS parser [1] was integrated and a set of whitelists implemented to offer various levels of capability/protection trade-offs.

For example, some wikis may want all CSS selectors prefixed with "#mw-content-text" and properties like "position", etc. disabled to limit the effect of styles to the article content. Other sites may want everything except XSS-able properties/values."

[1] https://github.com/sabberworm/PHP-CSS-Parser
Comment 2 Quim Gil 2013-10-31 05:22:57 UTC
This project proposal is now featured at https://www.mediawiki.org/wiki/Outreach_Program_for_Women/Round_7
Comment 3 Chris Steipp 2013-10-31 16:17:01 UTC
(In reply to comment #1)
> "The CSS extension relies on basic blacklisting functionality in MediaWiki
> core
> to prevent XSS. It would be great if a proper CSS parser [1] was integrated
> and
> a set of whitelists implemented to offer various levels of
> capability/protection trade-offs.

This sounds like a great project. I'd recommend looking at HTML Purifier's CSS rules as well, which would be great to integrate into either the extension, or core's CSS sanitization.

> [1] https://github.com/sabberworm/PHP-CSS-Parser
Comment 4 Bawolff (Brian Wolff) 2013-12-13 23:36:29 UTC
> 
> There are good reasons for the parser to strip some CSS out, but in addition
> to
> documenting this issue (which this bug does, and I'll do in the extension
> docs
> in a moment), it should be configurable whether the CSS extension lets the
> parser sanitize, for example, when used on private wikis.

The reason sanitizer doesn't let that through, is we don't want people to be able to load external resources from inline css
*This could in theory be used as a DOS attack against somebody else if someone put it on a popular page.
*It can be used to track users, and associate usernames with ip addresses (i.e. have {{REVISIONUSER}} in the query string of the external resource.

(There could be other resons. Those two are just the two I know about)
Comment 5 MZMcBride 2013-12-14 06:25:49 UTC
Bug 57891 is not an appropriate "see also"; removing.
Comment 6 Quim Gil 2014-09-12 09:19:20 UTC
A new round of FOSS OPW is coming. Should we keep https://www.mediawiki.org/wiki/Mentorship_programs/Possible_projects#Allowing_3rd_party_wiki_editors_to_run_more_CSS_features as a featured project? Meaning, does this project still make sense and are there mentors still available?

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


Navigation
Links