Steps to replicate the issue
What happens?:
The source code is rendered by the browser as arbitrary HTML.
What should have happened instead?:
Served as plain text like this URL does, for the same content:
We go through great lengths in MediaWiki to make sure our endpoints do not allow serving of arbitrary HTML. For example we set X-Content-Type-Options: nosniff, and we carefully escape any free-form text in api.php and rest.php responses that use JSON format to ensure no HTML-like tags are served as-is but rather use redundant slash escaping to prevent looking like HTML.
Other information
During today's worm accident (T419137), there was briefly talk in the #technical channel unofficial Discord about how to workaround the temporary user script disablement by using a Tampermonkey (GreaseMonkey) script. User:Sportzpikachu shared an approach that involved fetching https://en.wikipedia.org/w/index.php?title=Special:MyPage/common.js&action=raw&ctype=text/javascript and eval'ing its contents.
I would have thought such title is invalid for this entrypoint, but to my surprise it worked. And moreover, I noticed we respond with a text/html content type instead of the requested text/javascript. The workaround wasn't affected by that bug, because it didn't rely on the content type header and treated the response as plain text.
See also:
