The Cargo extension inserts the values of two URL parameters into raw SQL without escaping them, allowing for SQL injection.
Reproduction steps
- Create Template:Author:
<noinclude>{{#cargo_declare:_table=Authors|Birthday=Date}}</noinclude> <includeonly>{{#cargo_store:_table=Authors}}</includeonly>
- Create the cargo table at /w/index.php?title=Template:Author&action=recreatedata
- Create a page with the following contents: {{Author|Birthday=2024-01-01}}
- Go to /wiki/Special:CargoExport?format=fullcalendar&tables=Authors&fields=Birthday&start=2025-01-01%27))%20OR%20SLEEP(5);--%20 and observe that the query takes 5s to load, because the SLEEP() function is executed.
Cause
$datesLowerLimit and $datesUpperLimit are retrieved from the start and end request parameters:
https://github.com/wikimedia/mediawiki-extensions-Cargo/blob/5b7fe938f3bb4c758d8a58fbe36cdeee2bb4f1a6/includes/specials/CargoExport.php#L128-L129
Both variables are then inserted into raw SQL without any escaping being done:
https://github.com/wikimedia/mediawiki-extensions-Cargo/blob/5b7fe938f3bb4c758d8a58fbe36cdeee2bb4f1a6/includes/specials/CargoExport.php#L150
The payload 2025-01-01')) OR SLEEP(5);-- can therefore be used to break out of the single quotes and inject arbitrary SQL.
Additional information
- MediaWiki: 1.45.0-alpha
- Cargo: b304b24