CVE-2023-29198: Electron Electron Context Isolation Bypass Vulnerability

MODERATE
Advisory Identifier: GHSA-p7v2-p9m8-qqg7
CVSS 6.0
CWE-754
Published
Advisory Summary

CVE-2023-29198 is a MODERATE (CVSS 6.0) electron context isolation bypass vulnerability (CWE-754: Improper Check for Unusual or Exceptional Conditions) affecting Electron libraries in the npm ecosystem. The issue involves electron context isolation bypass via nested unserializable return value. Remediation is available by upgrading affected packages to version 22.3.6, 23.2.3, 24.0.1, 25.0.0-alpha.2.

CVE-2023-29198 at a Glance

CVE Identifier CVE-2023-29198
GHSA Identifier GHSA-p7v2-p9m8-qqg7
Severity MODERATE
CVSS v3.1 Base Score 6.0
CWE Classification CWE-754: Improper Check for Unusual or Exceptional Conditions
Affected Product Electron
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 6.0

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

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

How to Fix CVE-2023-29198

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

electron fixed: 22.3.6
npm install electron@22.3.6
electron fixed: 23.2.3
npm install electron@23.2.3
electron fixed: 24.0.1
npm install electron@24.0.1
electron fixed: 25.0.0-alpha.2
npm install electron@25.0.0-alpha.2
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 electron

How to Check if You Are Affected

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

npm ls electron

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

Note: The npm ls electron 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-754: Improper Check for Unusual or Exceptional Conditions, where the product does not check or incorrectly checks for unusual or exceptional conditions that are not expected to occur frequently during day to day operation of the product. In Electron, 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 Apps using `contextIsolation` and `contextBridge` are affected. This is a context isolation bypass, meaning that code running in the main world context in the renderer can reach into the isolated Electron context and perform privileged actions. ### Workarounds This issue is exploitable under either of two conditions: * If an API exposed to the main world via `contextBridge` can return an object or array that contains a JS object which cannot be serialized, for instance, a canvas rendering context. This would normally result in an exception being thrown `Error: object could not be cloned`. * If an API exposed to the main world via `contextBridge` has a return value that throws a user-generated exception while being sent over the bridge, for instance a dynamic getter property on an object that throws an error when being computed. The app side workaround is to ensure that such a case is not possible. Ensure all values returned from a function exposed over the context bridge are [supported](https://www.electronjs.org/docs/latest/api/context-bridge#parameter--error--return-type-support) and that any objects returned from functions do not have dynamic getters that can throw exceptions. Auditing your exposed API is likely to be quite difficult so we strongly recommend you update to a patched version of Electron. ### Fixed Versions * `25.0.0-alpha.2` * `24.0.1` * `23.2.3` * `22.3.6` ### For more information If you have any questions or comments about this advisory, email us at [security@electronjs.org](mailto:security@electronjs.org)

CVE-2023-29198 Affected Electron Versions

4 component(s)
Fixed Versions:
22.3.623.2.324.0.125.0.0-alpha.2
Product / Package Ecosystem Affected Versions Fixed Version
electron
npm
< 22.3.6
22.3.6
electron
npm
≥ 23.0.0-alpha.1
< 23.2.3
23.2.3
electron
npm
≥ 24.0.0-alpha.1
< 24.0.1
24.0.1
electron
npm
≥ 25.0.0-alpha.1
< 25.0.0-alpha.2
25.0.0-alpha.2

References

Frequently Asked Questions

What is CVE-2023-29198?
CVE-2023-29198 is a security vulnerability in Electron involving Electron context isolation bypass via nested unserializable return value under CWE-754: Improper Check for Unusual or Exceptional Conditions.
Which Electron versions are affected?
Affected versions include releases prior to 22.3.6, 23.2.3, 24.0.1, 25.0.0-alpha.2 across affected packages: electron.
What version fixes CVE-2023-29198?
Upgrading to 22.3.6, 23.2.3, 24.0.1, 25.0.0-alpha.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is electron affected?
Yes, electron is affected in releases prior to 22.3.6, 23.2.3, 24.0.1, 25.0.0-alpha.2. Upgrade your dependency to 22.3.6, 23.2.3, 24.0.1, 25.0.0-alpha.2 or later.
What is the CVSS score of CVE-2023-29198?
CVE-2023-29198 has a CVSS v3.1 base score of 6.0 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:L/I:L/A:L.
What CWE is associated with CVE-2023-29198?
CVE-2023-29198 is classified under CWE-754: Improper Check for Unusual or Exceptional Conditions (The product does not check or incorrectly checks for unusual or exceptional conditions that are not expected to occur frequently during day to day operation of the product.).
How can I check npm dependencies for CVE-2023-29198?
Run the dependency tree command: 'npm ls electron'. 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-p7v2-p9m8-qqg7",
  "modified" : "2023-09-06T19:50:58Z",
  "published" : "2023-09-06T19:50:58Z",
  "aliases" : [ "CVE-2023-29198" ],
  "summary" : "Electron context isolation bypass via nested unserializable return value",
  "details" : "### Impact\nApps using `contextIsolation` and `contextBridge` are affected.\n\nThis is a context isolation bypass, meaning that code running in the main world context in the renderer can reach into the isolated Electron context and perform privileged actions.\n\n### Workarounds\nThis issue is exploitable under either of two conditions:\n* If an API exposed to the main world via `contextBridge` can return an object or array that contains a JS object which cannot be serialized, for instance, a canvas rendering context. This would normally result in an exception being thrown `Error: object could not be cloned`.\n* If an API exposed to the main world via `contextBridge` has a return value that throws a user-generated exception while being sent over the bridge, for instance a dynamic getter property on an object that throws an error when being computed.\n\nThe app side workaround is to ensure that such a case is not possible. Ensure all values returned from a function exposed over the context bridge are [supported](https://www.electronjs.org/docs/latest/api/context-bridge#parameter--error--return-type-support) and that any objects returned from functions do not have dynamic getters that can throw exceptions.\n\nAuditing your exposed API is likely to be quite difficult so we strongly recommend you update to a patched version of Electron.\n\n### Fixed Versions\n* `25.0.0-alpha.2`\n* `24.0.1`\n* `23.2.3`\n* `22.3.6`\n\n### For more information\nIf you have any questions or comments about this advisory, email us at [security@electronjs.org](mailto:security@electronjs.org)",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:L/I:L/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "electron"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "22.3.6"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "electron"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "23.0.0-alpha.1"
      }, {
        "fixed" : "23.2.3"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "electron"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "24.0.0-alpha.1"
      }, {
        "fixed" : "24.0.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "electron"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "25.0.0-alpha.1"
      }, {
        "fixed" : "25.0.0-alpha.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/electron/electron/security/advisories/GHSA-p7v2-p9m8-qqg7"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-29198"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/electron/electron"
  }, {
    "type" : "WEB",
    "url" : "https://www.electronjs.org/docs/latest/api/context-bridge#parameter--error--return-type-support"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-754" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-09-06T19:50:58Z",
    "nvd_published_at" : "2023-09-06T21:15:11Z"
  }
}