CVE-2023-35931: Shescape Shescape Potential Environment Variable Exposure Vulnerability

LOW
Advisory Identifier: GHSA-3g7p-8qhx-mc8r
CVSS 3.1
CWE-526
Published
Advisory Summary

CVE-2023-35931 is a LOW (CVSS 3.1) shescape potential environment variable exposure vulnerability (CWE-526: Cleartext Storage of Sensitive Information in an Environment Variable) affecting Shescape libraries in the npm ecosystem. The issue involves shescape potential environment variable exposure on windows with cmd. Remediation is available by upgrading affected packages to version 1.7.1.

CVE-2023-35931 at a Glance

CVE Identifier CVE-2023-35931
GHSA Identifier GHSA-3g7p-8qhx-mc8r
Severity LOW
CVSS v3.1 Base Score 3.1
CWE Classification CWE-526: Cleartext Storage of Sensitive Information in an Environment Variable
Affected Product Shescape
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 3.1

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:U/C:L/I:N/A:N).

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

How to Fix CVE-2023-35931

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

shescape fixed: 1.7.1
npm install shescape@1.7.1
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 shescape

How to Check if You Are Affected

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

npm ls shescape

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

Note: The npm ls shescape 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-526: Cleartext Storage of Sensitive Information in an Environment Variable, where the product uses an environment variable to store unencrypted sensitive information. In Shescape, 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 impact users of Shescape: 1. On Windows using the Windows Command Prompt (i.e. `cmd.exe`), and 2. Using `quote`/`quoteAll` or `escape`/`escapeAll` with the `interpolation` option set to `true`. An attacker may be able to get read-only access to environment variables. Example: ```javascript import * as cp from "node:child_process"; import * as shescape from "shescape"; // 1. Prerequisites const options = { shell: "cmd.exe", // Or shell: undefined, // Only if the default shell is CMD // And interpolation: true, // Only applies to `escape` and `escapeAll` usage } // 2. Attack (one of many) const payload = "%PATH%"; // 3. Usage let escapedPayload; escapedPayload = shescape.quote(payload, options); // Or escapedPayload = shescape.quoteAll([payload], options); // Or escapedPayload = shescape.escape(payload, options); // Or escapedPayload = shescape.escapeAll([payload], options); // And (example) const result = cp.execSync(`echo Hello ${escapedPayload}`, options); // 4. Impact console.log(result.toString()); // Outputs "Hello" followed by the contents of the PATH environment variable ``` ### Patches This bug has been patched in [v1.7.1](https://github.com/ericcornelissen/shescape/releases/tag/v1.7.1) which you can upgrade to now. No further changes are required. ### Workarounds Alternatively, users can remove all instances of `%` from user input, either before or after using Shescape. ### References - Shescape Pull request [#982](https://github.com/ericcornelissen/shescape/pull/982) - Shescape commit [`d0fce70`](https://github.com/ericcornelissen/shescape/commit/d0fce70f987ac0d8331f93cb45d47e79436173ac) - Shescape Release [v1.7.1](https://github.com/ericcornelissen/shescape/releases/tag/v1.7.1)

CVE-2023-35931 Affected Shescape Versions

1 component(s)
Fixed Versions:
1.7.1
Product / Package Ecosystem Affected Versions Fixed Version
shescape
npm
< 1.7.1
1.7.1

References

Frequently Asked Questions

What is CVE-2023-35931?
CVE-2023-35931 is a security vulnerability in Shescape involving Shescape potential environment variable exposure on Windows with CMD under CWE-526: Cleartext Storage of Sensitive Information in an Environment Variable.
Which Shescape versions are affected?
Affected versions include releases prior to 1.7.1 across affected packages: shescape.
What version fixes CVE-2023-35931?
Upgrading to 1.7.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is shescape affected?
Yes, shescape is affected in releases prior to 1.7.1. Upgrade your dependency to 1.7.1 or later.
What is the CVSS score of CVE-2023-35931?
CVE-2023-35931 has a CVSS v3.1 base score of 3.1 (LOW) with vector string CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:N/A:N.
What CWE is associated with CVE-2023-35931?
CVE-2023-35931 is classified under CWE-526: Cleartext Storage of Sensitive Information in an Environment Variable (The product uses an environment variable to store unencrypted sensitive information.).
How can I check npm dependencies for CVE-2023-35931?
Run the dependency tree command: 'npm ls shescape'. 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-3g7p-8qhx-mc8r",
  "modified" : "2023-06-26T16:35:03Z",
  "published" : "2023-06-22T20:01:39Z",
  "aliases" : [ "CVE-2023-35931" ],
  "summary" : "Shescape potential environment variable exposure on Windows with CMD",
  "details" : "### Impact\n\nThis impact users of Shescape:\n\n1. On Windows using the Windows Command Prompt (i.e. `cmd.exe`), and\n2. Using `quote`/`quoteAll` or `escape`/`escapeAll` with the `interpolation` option set to `true`.\n\nAn attacker may be able to get read-only access to environment variables. Example:\n\n```javascript\nimport * as cp from \"node:child_process\";\nimport * as shescape from \"shescape\";\n\n// 1. Prerequisites\nconst options = {\n    shell: \"cmd.exe\",\n    // Or\n    shell: undefined, // Only if the default shell is CMD\n\n    // And\n    interpolation: true, // Only applies to `escape` and `escapeAll` usage\n}\n\n// 2. Attack (one of many)\nconst payload = \"%PATH%\";\n\n// 3. Usage\nlet escapedPayload;\n\nescapedPayload = shescape.quote(payload, options);\n// Or\nescapedPayload = shescape.quoteAll([payload], options);\n// Or\nescapedPayload = shescape.escape(payload, options);\n// Or\nescapedPayload = shescape.escapeAll([payload], options);\n\n// And (example)\nconst result = cp.execSync(`echo Hello ${escapedPayload}`, options);\n\n// 4. Impact\nconsole.log(result.toString());\n// Outputs \"Hello\" followed by the contents of the PATH environment variable\n```\n\n### Patches\n\nThis bug has been patched in [v1.7.1](https://github.com/ericcornelissen/shescape/releases/tag/v1.7.1) which you can upgrade to now. No further changes are required.\n\n### Workarounds\n\nAlternatively, users can remove all instances of `%` from user input, either before or after using Shescape.\n\n### References\n\n- Shescape Pull request [#982](https://github.com/ericcornelissen/shescape/pull/982)\n- Shescape commit [`d0fce70`](https://github.com/ericcornelissen/shescape/commit/d0fce70f987ac0d8331f93cb45d47e79436173ac)\n- Shescape Release [v1.7.1](https://github.com/ericcornelissen/shescape/releases/tag/v1.7.1)\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "shescape"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.7.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/ericcornelissen/shescape/security/advisories/GHSA-3g7p-8qhx-mc8r"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-35931"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ericcornelissen/shescape/pull/982"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ericcornelissen/shescape/commit/d0fce70f987ac0d8331f93cb45d47e79436173ac"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/ericcornelissen/shescape"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ericcornelissen/shescape/releases/tag/v1.7.1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-526" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-06-22T20:01:39Z",
    "nvd_published_at" : "2023-06-23T20:15:09Z"
  }
}