CVE-2023-39956: Electron Electron Vulnerable To Out-of-package Code Vulnerability

MODERATE
Advisory Identifier: GHSA-7x97-j373-85x5
CVSS 6.1
CWE-94
Published
Advisory Summary

CVE-2023-39956 is a MODERATE (CVSS 6.1) electron vulnerable to out-of-package code vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Electron libraries in the npm ecosystem. The issue involves electron vulnerable to out-of-package code execution when launched with arbitrary cwd. Remediation is available by upgrading affected packages to version 22.3.19, 23.3.13, 24.7.1, 25.5.0, 26.0.0-beta.13.

CVE-2023-39956 at a Glance

CVE Identifier CVE-2023-39956
GHSA Identifier GHSA-7x97-j373-85x5
Severity MODERATE
CVSS v3.1 Base Score 6.1
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product Electron
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 6.1

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

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

How to Fix CVE-2023-39956

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.19
npm install electron@22.3.19
electron fixed: 23.3.13
npm install electron@23.3.13
electron fixed: 24.7.1
npm install electron@24.7.1
electron fixed: 25.5.0
npm install electron@25.5.0
electron fixed: 26.0.0-beta.13
npm install electron@26.0.0-beta.13
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-39956, 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.19), 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-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. 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 that are launched as command line executables are impacted. E.g. if your app exposes itself in the path as `myapp --help` Specifically this issue can only be exploited if the following conditions are met: * Your app is launched with an attacker-controlled working directory * The attacker has the ability to write files to that working directory This makes the risk quite low, in fact normally issues of this kind are considered outside of our threat model as similar to Chromium we exclude [Physically Local Attacks](https://github.com/electron/electron/security/advisories/GHSA-7x97-j373-85x5#:~:text=Physically%20Local%20Attacks) but given the ability for this issue to bypass certain protections like ASAR Integrity it is being treated with higher importance. Please bear this in mind when reporting similar issues in the future. ### Workarounds There are no app side workarounds, you must update to a patched version of Electron. ### Fixed Versions * `26.0.0-beta.13` * `25.5.0` * `24.7.1` * `23.3.13` * `22.3.19` ### 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-39956 Affected Electron Versions

5 component(s)
Fixed Versions:
22.3.1923.3.1324.7.125.5.026.0.0-beta.13
Product / Package Ecosystem Affected Versions Fixed Version
electron
npm
< 22.3.19
22.3.19
electron
npm
≥ 23.0.0-alpha.1
< 23.3.13
23.3.13
electron
npm
≥ 24.0.0-alpha.1
< 24.7.1
24.7.1
electron
npm
≥ 25.0.0-alpha.1
< 25.5.0
25.5.0
electron
npm
≥ 26.0.0-alpha.1
< 26.0.0-beta.13
26.0.0-beta.13

References

Frequently Asked Questions

What is CVE-2023-39956?
CVE-2023-39956 is a security vulnerability in Electron involving Electron vulnerable to out-of-package code execution when launched with arbitrary cwd under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which Electron versions are affected?
Affected versions include releases prior to 22.3.19, 23.3.13, 24.7.1, 25.5.0, 26.0.0-beta.13 across affected packages: electron.
What version fixes CVE-2023-39956?
Upgrading to 22.3.19, 23.3.13, 24.7.1, 25.5.0, 26.0.0-beta.13 (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.19, 23.3.13, 24.7.1, 25.5.0, 26.0.0-beta.13. Upgrade your dependency to 22.3.19, 23.3.13, 24.7.1, 25.5.0, 26.0.0-beta.13 or later.
What is the CVSS score of CVE-2023-39956?
CVE-2023-39956 has a CVSS v3.1 base score of 6.1 (MODERATE) with vector string CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:U/C:L/I:H/A:L.
What CWE is associated with CVE-2023-39956?
CVE-2023-39956 is classified under CWE-94: Improper Control of Generation of Code ('Code Injection') (The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.).
How can I check npm dependencies for CVE-2023-39956?
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-7x97-j373-85x5",
  "modified" : "2023-09-06T19:51:33Z",
  "published" : "2023-09-06T19:51:33Z",
  "aliases" : [ "CVE-2023-39956" ],
  "summary" : "Electron vulnerable to out-of-package code execution when launched with arbitrary cwd",
  "details" : "### Impact\nApps that are launched as command line executables are impacted.  E.g. if your app exposes itself in the path as `myapp --help`\n\nSpecifically this issue can only be exploited if the following conditions are met:\n* Your app is launched with an attacker-controlled working directory\n* The attacker has the ability to write files to that working directory\n\nThis makes the risk quite low, in fact normally issues of this kind are considered outside of our threat model as similar to Chromium we exclude [Physically Local Attacks](https://github.com/electron/electron/security/advisories/GHSA-7x97-j373-85x5#:~:text=Physically%20Local%20Attacks) but given the ability for this issue to bypass certain protections like ASAR Integrity it is being treated with higher importance.  Please bear this in mind when reporting similar issues in the future.\n\n### Workarounds\nThere are no app side workarounds, you must update to a patched version of Electron.\n\n### Fixed Versions\n* `26.0.0-beta.13`\n* `25.5.0`\n* `24.7.1`\n* `23.3.13`\n* `22.3.19`\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:L/AC:L/PR:L/UI:R/S:U/C:L/I:H/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "electron"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "22.3.19"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "electron"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "23.0.0-alpha.1"
      }, {
        "fixed" : "23.3.13"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "electron"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "24.0.0-alpha.1"
      }, {
        "fixed" : "24.7.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "electron"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "25.0.0-alpha.1"
      }, {
        "fixed" : "25.5.0"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "electron"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "26.0.0-alpha.1"
      }, {
        "fixed" : "26.0.0-beta.13"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/electron/electron/security/advisories/GHSA-7x97-j373-85x5"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-39956"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/electron/electron"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-94" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-09-06T19:51:33Z",
    "nvd_published_at" : "2023-09-06T21:15:13Z"
  }
}