ApprovedRevs replaces the __APPROVEDREVS__ magic word in the ParserAfterTidy hook, allowing the inline CSS sanitizer to be bypassed.
Reproduction steps
- Go to /wiki/Special:ExpandTemplates?wpInput=%3Cpre%20style%3D%22background%3A%20u__APPROVEDREVS__rl%28%27%2F%2Fhttp.cat%2F418%27%29%22%2F%3E
- Observe that an HTTP request to https://http.cat/418 is sent because the CSS sanitizer was bypassed
Cause
ApprovedRevs performs to magic word replacement in the ParserAfterTidy hook: https://github.com/wikimedia/mediawiki-extensions-ApprovedRevs/blob/caf00bf928471fe6e30e8b1d7d3fea1de524e37f/includes/ApprovedRevsHooks.php#L956-L973
When this hook is run, strip markers are already unstripped. Because user-provided attribute values in elements inserted via strip markers (like the pre tag) are generally not safely encoded to escape underscores or other wikitext syntax, the __APPROVEDREVS__ magic word will be replaced in the style attribute of the <pre> element.
Additional information
- MediaWiki: 1.46.0-alpha
- Approved Revs: caf00bf
