CVE-2022-23631: Superjson Remote Code Execution Vulnerability

CRITICAL
Advisory Identifier: GHSA-5888-ffcr-r425
CVSS 9.0
CWE-1321 CWE-94
Published
Advisory Summary

CVE-2022-23631 is a CRITICAL (CVSS 9.0) remote code execution vulnerability (CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')) affecting Superjson libraries in the npm ecosystem. The issue involves prototype pollution leading to remote code execution in superjson. Remediation is available by upgrading affected packages to version 1.8.1, 0.45.3.

CVE-2022-23631 at a Glance

CVE Identifier CVE-2022-23631
GHSA Identifier GHSA-5888-ffcr-r425
Severity CRITICAL
CVSS v3.1 Base Score 9.0
CWE Classification CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')
Affected Product Superjson
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 9.0

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

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
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-23631

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

superjson fixed: 1.8.1
npm install superjson@1.8.1
blitz fixed: 0.45.3
npm install blitz@0.45.3
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 superjson

How to Check if You Are Affected

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

npm ls superjson

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

Note: The npm ls superjson 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 Superjson, 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 critical vulnerability, as it allows to run arbitrary code on any server using superjson input, including a Blitz.js server, without prior authentication or knowledge. Attackers gain full control over the server so they could steal and manipulate data or attack further systems. The only requirement is that the server implements at least one endpoint which uses superjson during request processing. In the case of Blitz.js, it would be at least one RPC call. ### Patches This has been patched in superjson 1.8.1 and Blitz.js 0.45.3. If you are unable to upgrade to Blitz.js 0.45.3 in a timely manner, you can instead upgrade only superjson to version 1.8.1 using yarn resolutions are similar. Blitz versions < 0.45.3 are only affected because they used superjson versions < 1.8.1. ### Workarounds None ### For more information If you have any questions or comments about this advisory: * Open an issue in https://github.com/blitz-js/superjson * Email us at b@bayer.ws ### References * https://www.sonarsource.com/blog/blitzjs-prototype-pollution/

CVE-2022-23631 Affected Superjson Versions

2 component(s)
Fixed Versions:
1.8.10.45.3
Product / Package Ecosystem Affected Versions Fixed Version
superjson
npm
< 1.8.1
1.8.1
blitz
npm
< 0.45.3
0.45.3

References

Frequently Asked Questions

What is CVE-2022-23631?
CVE-2022-23631 is a security vulnerability in Superjson involving Prototype Pollution leading to Remote Code Execution in superjson under CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution').
Which Superjson versions are affected?
Affected versions include releases prior to 1.8.1, 0.45.3 across affected packages: superjson, blitz.
What version fixes CVE-2022-23631?
Upgrading to 1.8.1, 0.45.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is superjson affected?
Yes, superjson is affected in releases prior to 1.8.1. Upgrade your dependency to 1.8.1 or later.
Is blitz affected?
Yes, blitz is affected in releases prior to 0.45.3. Upgrade your dependency to 0.45.3 or later.
What is the CVSS score of CVE-2022-23631?
CVE-2022-23631 has a CVSS v3.1 base score of 9.0 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H.
What CWE is associated with CVE-2022-23631?
CVE-2022-23631 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-23631?
Run the dependency tree command: 'npm ls superjson'. 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-5888-ffcr-r425",
  "modified" : "2023-10-23T19:20:21Z",
  "published" : "2022-02-09T22:20:49Z",
  "aliases" : [ "CVE-2022-23631" ],
  "summary" : "Prototype Pollution leading to Remote Code Execution in superjson",
  "details" : "### Impact\n\nThis is critical vulnerability, as it allows to run arbitrary code on any server using superjson input, including a Blitz.js server, without prior authentication or knowledge. Attackers gain full control over the server so they could steal and manipulate data or attack further systems. The only requirement is that the server implements at least one endpoint which uses superjson during request processing. In the case of Blitz.js, it would be at least one RPC call. \n\n### Patches\nThis has been patched in superjson 1.8.1 and Blitz.js 0.45.3. \n\nIf you are unable to upgrade to Blitz.js 0.45.3 in a timely manner, you can instead upgrade only superjson to version 1.8.1 using yarn resolutions are similar. Blitz versions < 0.45.3 are only affected because they used superjson versions < 1.8.1.\n\n### Workarounds\nNone\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Open an issue in https://github.com/blitz-js/superjson\n* Email us at b@bayer.ws\n\n### References\n* https://www.sonarsource.com/blog/blitzjs-prototype-pollution/",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "superjson"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.8.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "blitz"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.45.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/blitz-js/superjson/security/advisories/GHSA-5888-ffcr-r425"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-23631"
  }, {
    "type" : "ADVISORY",
    "url" : "https://github.com/advisories/GHSA-5888-ffcr-r425"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/blitz-js/superjson"
  }, {
    "type" : "WEB",
    "url" : "https://www.sonarsource.com/blog/blitzjs-prototype-pollution"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1321", "CWE-94" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-02-09T22:20:49Z",
    "nvd_published_at" : "2022-02-09T22:15:00Z"
  }
}