The ProofreadPage extension improperly sanitizes multiline styles using Sanitizer::checkCSS before decoding HTML entities, which allows CSS syntax such as @import and url() to be inserted.
Reproduction steps
- Enable PDF uploads
- Upload a PDF called TestFile.pdf
- Import https://wikisource.org/wiki/MediaWiki:Proofreadpage_index_data_config.json into your wiki
- Go to /w/index.php?title=Index:TestFile.pdf&action=edit
- Insert body { background: &\#x75;rl(https://http.cat/418); } into the "CSS to be used in pages" field
- Save the page
- Go to /w/index.php?title=Page:TestFile.pdf&action=edit and observe that the background image is loaded from https://http.cat/418
- Create the page
- Observe that the background image is also loaded when viewing the page
Cause
This is similar to T368594.
User-provided CSS is retrieved and then sanitized and escaped using Sanitizer::checkCss and Sanitizer::escapeHtmlAllowEntities:
https://gerrit.wikimedia.org/g/mediawiki/extensions/ProofreadPage/+/eb8ddceaeb1c0421baed9297fc3c14334911c424/includes/Page/PageDisplayHandler.php#90
The result of this is added to a <style> tag when editing or viewing a page:
https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/ProofreadPage/+/eb8ddceaeb1c0421baed9297fc3c14334911c424/includes/Page/PageViewAction.php#55
https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/ProofreadPage/+/eb8ddceaeb1c0421baed9297fc3c14334911c424/includes/Page/EditPagePage.php#77
Sanitizer::checkCss is intended to be used for styles inside style attributes and not for multiline styles inside <style> elements. This leads to several dangerous at-rules being allowed, such as @import. While single and double quotes are escaped by Sanitizer::escapeHtmlAllowEntities, the use of this function allows HTML entities to be used to bypass checks for dangerous CSS syntax such as url().
Additional information
- MediaWiki: 1.45.0-alpha
- ProofreadPage: eb8ddce




