{"id":"CVE-2022-24752","aliases":["GHSA-2xmm-g482-4439"],"url":"https://o3.security/vulnerability/CVE-2022-24752","summary":"SQL Injection through sorting parameters in SyliusGridBundle","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)","published":"2022-03-15T14:40:13Z","modified":"2026-08-12T03:51:33.824351870Z","cvss":{"score":9.8,"severity":"CRITICAL","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"},"epss":null,"cisaKev":null,"exploitsKnown":0,"affectedPackages":[{"ecosystem":"Packagist","name":"sylius/grid-bundle","fixedVersion":"1.10.1"}],"fix":{"url":"https://github.com/Sylius/SyliusGridBundle/commit/73d0791d0575f955e830a3da4c3345f420d2f784","label":"Sylius/SyliusGridBundle@73d0791"},"references":[{"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"},{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2022/24xxx/CVE-2022-24752.json"},{"type":"ADVISORY","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":"FIX","url":"https://github.com/Sylius/SyliusGridBundle/commit/73d0791d0575f955e830a3da4c3345f420d2f784"},{"type":"FIX","url":"https://github.com/Sylius/SyliusGridBundle/pull/222"},{"type":"PACKAGE","url":"https://github.com/Sylius/SyliusGridBundle"}],"provenance":{"sources":["OSV.dev","FIRST.org (EPSS)"],"lastVerified":"2026-08-12T03:51:33.824351870Z"}}