CVE-2023-38695: @simonsmith/cypress image snapshot @simonsmith/cypress-image-snapshothas Fix For Insecure Snapshot Vulnerability

MODERATE
Advisory Identifier: GHSA-vxjg-hchx-cc4g
CVSS 6.5
CWE-22
Published
Advisory Summary

CVE-2023-38695 is a MODERATE (CVSS 6.5) @simonsmith/cypress-image-snapshothas fix for insecure snapshot vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting @simonsmith/cypress image snapshot libraries in the npm ecosystem. The issue involves @simonsmith/cypress-image-snapshothas fix for insecure snapshot file names. Remediation is available by upgrading affected packages to version 8.0.2.

CVE-2023-38695 at a Glance

CVE Identifier CVE-2023-38695
GHSA Identifier GHSA-vxjg-hchx-cc4g
Severity MODERATE
CVSS v3.1 Base Score 6.5
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product @simonsmith/cypress image snapshot
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 6.5

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

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

How to Fix CVE-2023-38695

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

@simonsmith/cypress-image-snapshot fixed: 8.0.2
npm install @simonsmith/cypress-image-snapshot@8.0.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 @simonsmith/cypress-image-snapshot

How to Check if You Are Affected

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

npm ls @simonsmith/cypress-image-snapshot

Analyze the terminal output to locate any version of @simonsmith/cypress image snapshot in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 8.0.2), your application is affected.

Note: The npm ls @simonsmith/cypress-image-snapshot 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-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In @simonsmith/cypress image snapshot, 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 It's possible for a user to pass a relative file path for the snapshot name and reach outside of the project directory into the machine running the test. Example: ```js cy.get('h1').matchImageSnapshot('../../../ignore-relative-dirs') ``` The above will create an `ignore-relative-dirs.png` three levels up ### Patches Fixed in `8.0.2` ### Workarounds Validate all the existing uses of `matchImageSnapshot` to ensure correct use of the filename argument. Example: ```js // snapshot name will be the test title cy.matchImageSnapshot(); // snapshot name will be the name passed in cy.matchImageSnapshot('login'); ``` ### References https://github.com/simonsmith/cypress-image-snapshot/issues/15

CVE-2023-38695 Affected @simonsmith/cypress image snapshot Versions

1 component(s)
Fixed Versions:
8.0.2
Product / Package Ecosystem Affected Versions Fixed Version
@simonsmith/cypress-image-snapshot
npm
< 8.0.2
8.0.2

References

Frequently Asked Questions

What is CVE-2023-38695?
CVE-2023-38695 is a security vulnerability in @simonsmith/cypress image snapshot involving @simonsmith/cypress-image-snapshothas fix for insecure snapshot file names under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which @simonsmith/cypress image snapshot versions are affected?
Affected versions include releases prior to 8.0.2 across affected packages: @simonsmith/cypress-image-snapshot.
What version fixes CVE-2023-38695?
Upgrading to 8.0.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @simonsmith/cypress-image-snapshot affected?
Yes, @simonsmith/cypress-image-snapshot is affected in releases prior to 8.0.2. Upgrade your dependency to 8.0.2 or later.
What is the CVSS score of CVE-2023-38695?
CVE-2023-38695 has a CVSS v3.1 base score of 6.5 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N.
What CWE is associated with CVE-2023-38695?
CVE-2023-38695 is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.).
How can I check npm dependencies for CVE-2023-38695?
Run the dependency tree command: 'npm ls @simonsmith/cypress-image-snapshot'. 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-vxjg-hchx-cc4g",
  "modified" : "2023-08-04T18:41:47Z",
  "published" : "2023-08-01T16:59:40Z",
  "aliases" : [ "CVE-2023-38695" ],
  "summary" : "@simonsmith/cypress-image-snapshothas fix for insecure snapshot file names",
  "details" : "### Impact\nIt's possible for a user to pass a relative file path for the snapshot name and reach outside of the project directory into the machine running the test. Example:\n\n```js\n  cy.get('h1').matchImageSnapshot('../../../ignore-relative-dirs')\n```\nThe above will create an `ignore-relative-dirs.png` three levels up\n\n### Patches\nFixed in `8.0.2`\n\n### Workarounds\nValidate all the existing uses of `matchImageSnapshot` to ensure correct use of the filename argument. Example:\n\n```js\n    // snapshot name will be the test title\n    cy.matchImageSnapshot();\n\n    // snapshot name will be the name passed in\n    cy.matchImageSnapshot('login');\n```\n\n### References\nhttps://github.com/simonsmith/cypress-image-snapshot/issues/15\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@simonsmith/cypress-image-snapshot"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "8.0.2"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 8.0.1"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/simonsmith/cypress-image-snapshot/security/advisories/GHSA-vxjg-hchx-cc4g"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-38695"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/simonsmith/cypress-image-snapshot/issues/15"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/simonsmith/cypress-image-snapshot/commit/ef49519795daf5183f4fac6f3136e194f20f39f4"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/simonsmith/cypress-image-snapshot"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/simonsmith/cypress-image-snapshot/releases/tag/8.0.2"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-08-01T16:59:40Z",
    "nvd_published_at" : "2023-08-04T18:15:14Z"
  }
}