CVE-2022-24760: Parse server Command Injection Vulnerability

CRITICAL
Advisory Identifier: GHSA-p6h4-93qp-jhcm
CVSS 10.0
CWE-1321 CWE-74
Published
Advisory Summary

CVE-2022-24760 is a CRITICAL (CVSS 10.0) command injection vulnerability (CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')) affecting Parse server libraries in the npm ecosystem. The issue involves command injection in parse server through prototype pollution. Remediation is available by upgrading affected packages to version 4.10.7.

CVE-2022-24760 at a Glance

CVE Identifier CVE-2022-24760
GHSA Identifier GHSA-p6h4-93qp-jhcm
Severity CRITICAL
CVSS v3.1 Base Score 10.0
CWE Classification CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')
Affected Product Parse server
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 10.0

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:C/C:H/I:H/A:H).

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

How to Fix CVE-2022-24760

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

parse-server fixed: 4.10.7
npm install parse-server@4.10.7
Verify Direct and Transitive Dependencies

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

npm ls parse-server

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2022-24760, inspect your project dependencies using npm:

npm ls parse-server

Analyze the terminal output to locate any version of Parse server in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.10.7), your application is affected.

Note: The npm ls parse-server command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution'), where the product receives input from an upstream component that specifies attributes that are to be initialized or updated in an object, but it does not properly control modifications of attributes of the object prototype. In Parse server, 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

### Impact This is a Remote Code Execution (RCE) vulnerability in Parse Server. This vulnerability affects Parse Server in the default configuration with MongoDB. The main weakness that leads to RCE is the Prototype Pollution vulnerable code in the file `DatabaseController.js`, so it is likely to affect Postgres and any other database backend as well. This vulnerability has been confirmed on Linux (Ubuntu) and Windows. ### Patches Upgrade to Parse Server >=4.10.7. If you are using a prerelease version of Parse Server 5.0 (alpha, beta) we will publish a timely fix for these. However, as a general reminder we do not consider prerelease versions to be suitable for production deployment. Note that as part of the fix a new security feature scans for sensitive keywords in request data to prevent JavaScript prototype pollution. If such a keyword is found, the request is rejected with HTTP response code `400` and Parse Error `105` (`INVALID_KEY_NAME`). By default these keywords are: `{_bsontype: "Code"}`, `constructor`, `__proto__`. If you are using any of these keywords in your request data, you can override the default keywords by setting the new Parse Server option `requestKeywordDenylist` to `[]` and specify your own keywords as needed. ### Workarounds Although the fix is more broad and includes several aspects of the vulnerability, a quick and targeted fix can be achieved by patching the MongoDB Node.js driver and disable BSON code execution. To apply the patch, add the following code to be executed before starting Parse Server, for example in `index.js`. ``` const BSON = require('bson'); const internalDeserialize = BSON.prototype.deserialize; BSON.prototype.deserialize = (buffer, options = Object.create(null), ...others) => { if (options.constructor) { options = Object.assign(Object.create(null), options); } return internalDeserialize(buffer, options, ...others); }; const internalDeserializeStream = BSON.prototype.deserializeStream; BSON.prototype.deserializeStream = ( data, startIndex, numberOfDocuments, documents, docStartIndex, options = Object.create(null), ...others ) => { if (options.constructor) { options = Object.assign(Object.create(null), options); } return internalDeserializeStream( data, startIndex, numberOfDocuments, documents, docStartIndex, options, ...others ); }; ``` ### References - Original report on [huntr.dev](https://www.huntr.dev/bounties/ac24b343-e7da-4bc7-ab38-4f4f5cc9d099/)

CVE-2022-24760 Affected Parse server Versions

1 component(s)
Fixed Versions:
4.10.7
Product / Package Ecosystem Affected Versions Fixed Version
parse-server
npm
< 4.10.7
4.10.7

References

Frequently Asked Questions

What is CVE-2022-24760?
CVE-2022-24760 is a security vulnerability in Parse server involving Command injection in Parse Server through prototype pollution under CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution').
Which Parse server versions are affected?
Affected versions include releases prior to 4.10.7 across affected packages: parse-server.
What version fixes CVE-2022-24760?
Upgrading to 4.10.7 (or the latest patched release for your respective branch) resolves the vulnerability.
Is parse-server affected?
Yes, parse-server is affected in releases prior to 4.10.7. Upgrade your dependency to 4.10.7 or later.
What is the CVSS score of CVE-2022-24760?
CVE-2022-24760 has a CVSS v3.1 base score of 10.0 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H.
What CWE is associated with CVE-2022-24760?
CVE-2022-24760 is classified under CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution') (The product receives input from an upstream component that specifies attributes that are to be initialized or updated in an object, but it does not properly control modifications of attributes of the object prototype.).
How can I check npm dependencies for CVE-2022-24760?
Run the dependency tree command: 'npm ls parse-server'. 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-p6h4-93qp-jhcm",
  "modified" : "2022-04-19T18:24:25Z",
  "published" : "2022-03-11T23:53:23Z",
  "aliases" : [ "CVE-2022-24760" ],
  "summary" : "Command injection in Parse Server through prototype pollution",
  "details" : "### Impact\nThis is a Remote Code Execution (RCE) vulnerability in Parse Server. This vulnerability affects Parse Server in the default configuration with MongoDB. The main weakness that leads to RCE is the Prototype Pollution vulnerable code in the file `DatabaseController.js`, so it is likely to affect Postgres and any other database backend as well. This vulnerability has been confirmed on Linux (Ubuntu) and Windows.\n\n### Patches\nUpgrade to Parse Server >=4.10.7. If you are using a prerelease version of Parse Server 5.0 (alpha, beta) we will publish a timely fix for these. However, as a general reminder we do not consider prerelease versions to be suitable for production deployment.\n\nNote that as part of the fix a new security feature scans for sensitive keywords in request data to prevent JavaScript prototype pollution. If such a keyword is found, the request is rejected with HTTP response code `400` and Parse Error `105` (`INVALID_KEY_NAME`). By default these keywords are: `{_bsontype: \"Code\"}`, `constructor`, `__proto__`. If you are using any of these keywords in your request data, you can override the default keywords by setting the new Parse Server option `requestKeywordDenylist` to `[]` and specify your own keywords as needed.\n\n### Workarounds\nAlthough the fix is more broad and includes several aspects of the vulnerability, a quick and targeted fix can be achieved by patching the MongoDB Node.js driver and disable BSON code execution. To apply the patch, add the following code to be executed before starting Parse Server, for example in `index.js`.\n\n```\nconst BSON = require('bson');\n const internalDeserialize = BSON.prototype.deserialize;\n BSON.prototype.deserialize = (buffer, options = Object.create(null), ...others) => {\n   if (options.constructor) {\n     options = Object.assign(Object.create(null), options);\n   }\n   return internalDeserialize(buffer, options, ...others);\n };\n const internalDeserializeStream = BSON.prototype.deserializeStream;\n BSON.prototype.deserializeStream = (\n   data,\n   startIndex,\n   numberOfDocuments,\n   documents,\n   docStartIndex,\n   options = Object.create(null),\n   ...others\n ) => {\n   if (options.constructor) {\n     options = Object.assign(Object.create(null), options);\n   }\n   return internalDeserializeStream(\n     data,\n     startIndex,\n     numberOfDocuments,\n     documents,\n     docStartIndex,\n     options,\n     ...others\n   );\n };\n```\n\n### References\n- Original report on [huntr.dev](https://www.huntr.dev/bounties/ac24b343-e7da-4bc7-ab38-4f4f5cc9d099/)\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "parse-server"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.10.7"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/parse-community/parse-server/security/advisories/GHSA-p6h4-93qp-jhcm"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-24760"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/parse-community/parse-server/commit/886bfd7cac69496e3f73d4bb536f0eec3cba0e4d"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/parse-community/parse-server"
  }, {
    "type" : "WEB",
    "url" : "https://www.huntr.dev/bounties/ac24b343-e7da-4bc7-ab38-4f4f5cc9d099"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1321", "CWE-74" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-03-11T23:53:23Z",
    "nvd_published_at" : "2022-03-12T00:15:00Z"
  }
}