Impact
An unauthenticated attacker may exfiltrate sensitive data from the database (Special:Drilldown is accessible to anonymous users by default).
Description
The Special:Drilldown page defined by the Cargo extension provides filtering using CargoAppliedFilter.php. The checkSQL() function in that file performs a number of SQL string concatenations with user supplied input.
$sql .= "date($value_field) >= date('$date_string') ";
Similar string concatenation patterns exist in other branches within that function.
Reproduction
Replace TABLENAME with the name of a table containing a Date field, and replace DATEFIELDNAME with the name of that Date field.
Returns all records:
Special:Drilldown/TABLENAME?_lower_DATEFIELDNAME[year]=1&_lower_DATEFIELDNAME[month]=1&_lower_DATEFIELDNAME[day]=1%27)%20AND%20(%271%27=%271
Returns no records:
Special:Drilldown/TABLENAME?_lower_DATEFIELDNAME[year]=1&_lower_DATEFIELDNAME[month]=1&_lower_DATEFIELDNAME[day]=1%27)%20AND%20(%272%27=%271
These queries are benign and intended only to show the existence of the vulnerability (AND 1=1 versus AND 2=1), rather than demonstrate the worst case impact.
Recommendation
Use MediaWiki database abstractions to build parameterized queries, rather than concatenating strings.
https://www.mediawiki.org/wiki/Manual:Database_access#SelectQueryBuilder
Review other code within the Cargo extension for SQL string concatenation and SQL injection vulnerabilities.