On test.wikipedia.org, \bbadsite\.com\b is blacklisted. I added a whitelist entry for \bbadsite\.com/page\b, the standard format for a whitelist entry on Wikimedia sites. Whitelisting worked as intended, however I was also able to add the URL https://badsite.com/page/../badpage. As can be seen with these real-world examples in my enwiki sandbox, I was able to use this exploit to link to real sales pages on Kickstarter and Ticketmaster, which are both blacklisted on enwiki.
URL parameters are also a vulnerability. For instance, on MediaWiki sites, ?diff= and ?oldid= override the title, so if some wiki were blacklisted but its Main Page were whitelisted, any page can be linked to with Main_Page?oldid=....
It's very rare that a trailing slash or an anchor will lead to a new page, so the general solution here is to replace trailing \bs with /?(?:\x23\S*)?$ (\x23 is escaped #). Results of implementing that on testwiki:
- https://badsite.com/page works as intended
- https://badsite.com/page/ works as intended
- https://badsite.com/page/#anchor works as intended
- https://badsite.com/page#anchor works as intended
- https://badsite.com/page/../BadPage is blocked as intended
- https://badsite.com/page?realPage=BadPage is blocked as intended
- https://badsite.com/page/?realPage=BadPage is blocked as intended
- https://badsite.com/page/../BadPage#anchor is blocked as intended
I could just implement this myself on wikis where I have sysop, but I'm bringing it to a security ticket first because of the global implications. These could be changed en masse across Wikimedia wikis by a global interface editor, maybe with an entry in Tech News explaining why the change was made, so admins will know to stop using \b at the end of whitelist entries.
P.S. I haven't revdelled/logdelled any of my tests on enwiki or testwiki, because it seems easier for the ticket if everyone can see everything, and I don't think there's a massive risk to people finding out about this as long as we do something about it relatively soon. But I can delete stuff if that's deemed preferable.