Page MenuHomePhabricator

CVE-2026-13706: UrlShortener extension url validation can be bypassed due to difference between php url parsing and WHATWG
Closed, ResolvedPublicSecurity

Description

UrlShortner validates and parses urls based on MediaWiki's url parsing functions which are based on PHP's parse_url function with a couple fixes.

However, PHP's url parsing functions do not follow the WHATWG standard that web browsers use.

As a result you can shorten urls that you shouldn't be able to. For example: https://w.wiki/H$rD which goes to my personal website (Based on differing interpretations on how \ is handled in hostnames).

Inspired by T418431

Event Timeline

PHP 8.5 includes a WHATWG-compliant URL class: https://www.php.net/releases/8.5/en.php#new-uri-extension. There is a polyfill for PHP 8.1+: https://github.com/thephpleague/uri-polyfill.

I don't know if it's feasible to switch to that just for this one thing in UrlShortener. I hope that one day we switch to using it more generally (instead of parse_url and our own wfParseUrl/UrlUtils), but that will be a long effort, probably at least as much work as the switch we did on the JS side (T374314).

Failing converting to WHATWG compliant parser, just checking to make sure that the host part of the url does not contain \ would probably prevent the most serious issues

sbassett triaged this task as Medium priority.Mar 23 2026, 9:41 PM
sbassett added a project: Vuln-InputValidation.
sbassett changed Risk Rating from N/A to Medium.
sbassett added subscribers: Esanders, Umherirrender, sbassett.

Would this work as a simple security patch, for now, based upon @Bawolff's assessment above?


There appear to only be 20 urls currently within wikishared.urlshortcodes in Wikimedia production that have a \. pattern in them. And most of them appear to be false positives, within abnormal query parameter values. Though there are definitely a few where folks have clearly tried this trick:

+---------+
| usc_url |                                                                                                                                                                                                                              +---------+
http://www.google.com\.wikipedia.org/                                                                                                                                                                                                
http://www.google.com\.wikipedia.org/\..\                                                                                                                                                                                            
http://www.google.com\.wikipedia.org/\..\..\                                                                                                                                                                                        
http://tools.usps.com\.wikipedia.org/\..\..\go/TrackConfirmAction?qtc_tLabels1=9200190388491201512135                                                                                                                                
http://www.google.com\.wikipedia.org/\..\..\search?q=wikipedia&hl=en-US&safe=active#bfoot                                                                                                                                            
http://www.google.com\.wikipedia.org/..\search?q=wikipedia&hl=en-US&safe=active#bfoot                                                                                                                                                
http://www.google.com\.wikipedia.org/search?q=wikipedia&hl=en-US&safe=active#bfoot                                                                                                                                                   
http://www.youtube.com\.wikipedia.org/..\watch?v=dQw4w9WgXcQ
sbassett changed the task status from Open to In Progress.Mar 24 2026, 4:16 PM
sbassett moved this task from Watching to In Progress on the Security-Team board.

Any reason this patch can't actually go through gerrit? It's not a bundled extension etc.

Security release due this week, so would be good to start clearing up the WMF deployed board

Any reason this patch can't actually go through gerrit? It's not a bundled extension etc.

It can go out with the supplemental, we have it tracked there.

Change #1306273 had a related patch set uploaded (by Reedy; author: SBassett):

[mediawiki/extensions/UrlShortener@master] SECURITY: remove backslashes from host portion of parsed url

https://gerrit.wikimedia.org/r/1306273

Reedy renamed this task from UrlShortener extension url validation can be bypassed due to difference between php url parsing and WHATWG to CVE-2026-13706: UrlShortener extension url validation can be bypassed due to difference between php url parsing and WHATWG.Jun 29 2026, 1:21 PM

Change #1306273 merged by jenkins-bot:

[mediawiki/extensions/UrlShortener@master] SECURITY: remove backslashes from host portion of parsed url

https://gerrit.wikimedia.org/r/1306273

Change #1306293 had a related patch set uploaded (by Reedy; author: SBassett):

[mediawiki/extensions/UrlShortener@REL1_46] SECURITY: remove backslashes from host portion of parsed url

https://gerrit.wikimedia.org/r/1306293

Change #1306294 had a related patch set uploaded (by Reedy; author: SBassett):

[mediawiki/extensions/UrlShortener@REL1_45] SECURITY: remove backslashes from host portion of parsed url

https://gerrit.wikimedia.org/r/1306294

Change #1306295 had a related patch set uploaded (by Reedy; author: SBassett):

[mediawiki/extensions/UrlShortener@REL1_44] SECURITY: remove backslashes from host portion of parsed url

https://gerrit.wikimedia.org/r/1306295

Change #1306297 had a related patch set uploaded (by Reedy; author: SBassett):

[mediawiki/extensions/UrlShortener@REL1_43] SECURITY: remove backslashes from host portion of parsed url

https://gerrit.wikimedia.org/r/1306297

Change #1306293 merged by jenkins-bot:

[mediawiki/extensions/UrlShortener@REL1_46] SECURITY: remove backslashes from host portion of parsed url

https://gerrit.wikimedia.org/r/1306293

Change #1306295 merged by jenkins-bot:

[mediawiki/extensions/UrlShortener@REL1_44] SECURITY: remove backslashes from host portion of parsed url

https://gerrit.wikimedia.org/r/1306295

Change #1306294 merged by Reedy:

[mediawiki/extensions/UrlShortener@REL1_45] SECURITY: remove backslashes from host portion of parsed url

https://gerrit.wikimedia.org/r/1306294

Change #1306297 merged by Reedy:

[mediawiki/extensions/UrlShortener@REL1_43] SECURITY: remove backslashes from host portion of parsed url

https://gerrit.wikimedia.org/r/1306297

sbassett changed the visibility from "Custom Policy" to "Public (No Login Required)".
sbassett changed the edit policy from "Custom Policy" to "All Users".
sbassett removed a project: Patch-For-Review.