The vulnerability is a SQL injection in the TotalRevenue widget of Craft Commerce, which can be escalated to remote code execution. The root cause is the lack of input sanitization on the type parameter of the TotalRevenue widget. This parameter is used to construct a SQL query in the getData method of the craftcms\commerce\stats\TotalRevenue class.
The patch addresses this vulnerability in two places:
- In
src/widgets/TotalRevenue.php, a new defineRules method is added to the TotalRevenue widget to validate the type parameter, ensuring it is one of the allowed values. This is a preventative measure at the input boundary.
- In
src/stats/TotalRevenue.php, the getData method is modified to include a check that validates the type property before it is used in the SQL query. This is a direct fix for the SQL injection vulnerability.
Therefore, the craftcms\commerce\stats\TotalRevenue::getData function is the primary vulnerable function where the SQL injection occurs. The craftcms\commerce\widgets\TotalRevenue widget is the entry point for the malicious input, and the lack of validation in this widget (prior to the patch) is a key part of the vulnerability chain.