CVE-2022-24752: Sylius/grid bundle DQL Injection Through Sorting Parameters Vulnerability
CRITICALCVE-2022-24752 is a CRITICAL (CVSS 9.8) dql injection through sorting parameters vulnerability (CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')) affecting Sylius/grid bundle libraries in the Packagist ecosystem. The issue involves dql injection through sorting parameters blocked. Remediation is available by upgrading affected packages to version 1.10.1.
CVE-2022-24752 at a Glance
Security Impact
CVSS: 9.8
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H).
How to Fix CVE-2022-24752
To remediate this vulnerability, upgrade all affected Sylius/grid bundle dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade sylius/grid-bundle to 1.10.1
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for sylius/grid-bundle
How to Check if You Are Affected
To determine whether your application is affected by CVE-2022-24752, inspect your project dependencies for Sylius/grid bundle:
inspect dependencies for sylius/grid-bundle
Analyze the terminal output to locate any version of Sylius/grid bundle in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.10.1), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where the product constructs all or part of an sql command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended sql command when it is sent to a downstream component. without sufficient removal or quoting of sql syntax in user-controllable inputs, the generated sql query can cause those inputs to be interpreted as sql instead of ordinary user data. In Sylius/grid bundle, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2022-24752 Affected Sylius/grid bundle Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
sylius/grid-bundle
|
Packagist |
< 1.10.1
|
1.10.1
|
References
Frequently Asked Questions
What is CVE-2022-24752?
Which Sylius/grid bundle versions are affected?
What version fixes CVE-2022-24752?
Is sylius/grid-bundle affected?
What is the CVSS score of CVE-2022-24752?
What CWE is associated with CVE-2022-24752?
How can I check Packagist dependencies for CVE-2022-24752?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-2xmm-g482-4439",
"modified" : "2022-03-15T19:09:16Z",
"published" : "2022-03-15T19:09:16Z",
"aliases" : [ "CVE-2022-24752" ],
"summary" : "DQL injection through sorting parameters blocked",
"details" : "### Impact\nValues added at the end of query sorting were passed directly to the DB. We don't know, if it could lead to direct SQL injections, however, we should not allow for easy injection of values there anyway.\n\n### Patches\nThe issue is fixed in version 1.10.1 and in 1.11-rc.1\n\n### Workarounds\n\nYou have to overwrite your `Sylius\\Component\\Grid\\Sorting\\Sorter.php` class:\n\n```php\n<?php\n\n// src/App/Sorting/Sorter.php\n\ndeclare(strict_types=1);\n\nnamespace App\\Sorting;\n\nuse Symfony\\Component\\HttpKernel\\Exception\\BadRequestHttpException;\nuse Sylius\\Component\\Grid\\Data\\DataSourceInterface;\nuse Sylius\\Component\\Grid\\Definition\\Grid;\nuse Sylius\\Component\\Grid\\Parameters;\nuse Sylius\\Component\\Grid\\Sorting\\SorterInterface;\n\nfinal class Sorter implements SorterInterface\n{\n public function sort(DataSourceInterface $dataSource, Grid $grid, Parameters $parameters): void\n {\n $enabledFields = $grid->getFields();\n $expressionBuilder = $dataSource->getExpressionBuilder();\n\n $sorting = $parameters->get('sorting', $grid->getSorting());\n $this->validateSortingParams($sorting, $enabledFields);\n\n foreach ($sorting as $field => $order) {\n $this->validateFieldNames($field, $enabledFields);\n\n $gridField = $grid->getField($field);\n $property = $gridField->getSortable();\n\n if (null !== $property) {\n $expressionBuilder->addOrderBy($property, $order);\n }\n }\n }\n\n private function validateSortingParams(array $sorting, array $enabledFields): void\n {\n foreach (array_keys($enabledFields) as $key) {\n if (array_key_exists($key, $sorting) && !in_array($sorting[$key], ['asc', 'desc'])) {\n throw new BadRequestHttpException(sprintf('%s is not valid, use asc or desc instead.', $sorting[$key]));\n }\n }\n }\n\n private function validateFieldNames(string $fieldName, array $enabledFields): void\n {\n $enabledFieldsNames = array_keys($enabledFields);\n\n if (!in_array($fieldName, $enabledFieldsNames, true)) {\n throw new BadRequestHttpException(sprintf('%s is not valid field, did you mean one of these: %s?', $fieldName, implode(', ', $enabledFieldsNames)));\n }\n }\n}\n```\nand register it in your container: \n\n```yaml\n# config/services.yaml\nservices:\n # ...\n sylius.grid.sorter:\n class: App\\Sorting\\Sorter\n```\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Open an issue in [Sylius issues](https://github.com/Sylius/Sylius/issues)\n* Email us at [security@sylius.com](mailto:security@sylius.com)",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Packagist",
"name" : "sylius/grid-bundle"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.10.1"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/Sylius/SyliusGridBundle/security/advisories/GHSA-2xmm-g482-4439"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-24752"
}, {
"type" : "WEB",
"url" : "https://github.com/Sylius/SyliusGridBundle/pull/222"
}, {
"type" : "WEB",
"url" : "https://github.com/Sylius/SyliusGridBundle/commit/73d0791d0575f955e830a3da4c3345f420d2f784"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/Sylius/SyliusGridBundle"
}, {
"type" : "WEB",
"url" : "https://github.com/Sylius/SyliusGridBundle/releases/tag/v1.10.1"
}, {
"type" : "WEB",
"url" : "https://github.com/Sylius/SyliusGridBundle/releases/tag/v1.11.0-RC.2"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-89" ],
"severity" : "CRITICAL",
"github_reviewed" : true,
"github_reviewed_at" : "2022-03-15T19:09:16Z",
"nvd_published_at" : "2022-03-15T15:15:00Z"
}
}