CVE-2023-34238: Gatsby Gatsby Develop Server Has Local Vulnerability

MODERATE
Advisory Identifier: GHSA-c6f8-8r25-c4gc
CVSS 4.3
CWE-22
Published
Advisory Summary

CVE-2023-34238 is a MODERATE (CVSS 4.3) gatsby develop server has local vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Gatsby libraries in the npm ecosystem. The issue involves gatsby develop server has local file inclusion vulnerability. Remediation is available by upgrading affected packages to version 4.25.7, 5.9.1.

CVE-2023-34238 at a Glance

CVE Identifier CVE-2023-34238
GHSA Identifier GHSA-c6f8-8r25-c4gc
Severity MODERATE
CVSS v3.1 Base Score 4.3
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Gatsby
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 4.3

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:L/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 Low (C:L)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2023-34238

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

gatsby fixed: 4.25.7
npm install gatsby@4.25.7
gatsby fixed: 5.9.1
npm install gatsby@5.9.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 gatsby

How to Check if You Are Affected

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

npm ls gatsby

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

Note: The npm ls gatsby 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 Gatsby, 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 The Gatsby framework prior to versions 4.25.7 and 5.9.1 contain a Local File Inclusion vulnerability in the `__file-code-frame` and `__original-stack-frame` paths, exposed when running the Gatsby develop server (`gatsby develop`). The following steps can be used to reproduce the vulnerability: ``` # Create a new Gatsby project $ npm init gatsby $ cd my-gatsby-site # Start the Gatsby develop server $ gatsby develop # Execute the Local File Inclusion vulnerability in __file-code-frame $ curl "http://127.0.0.1:8000/__file-code-frame?filePath=/etc/passwd&lineNumber=1" # Execute the Local File Inclusion vulnerability in __original-stack-frame $ curl "http://127.0.0.1:8000/__original-stack-frame?moduleId=/etc/hosts&lineNumber=1&skipSourceMap=1" ``` It should be noted that by default `gatsby develop` is only accessible via the localhost `127.0.0.1`, and one would need to intentionally expose the server to other interfaces to exploit this vulnerability by using server options such as `--host 0.0.0.0`, `-H 0.0.0.0`, or the `GATSBY_HOST=0.0.0.0` environment variable. ### Patches A patch has been introduced in `gatsby@5.9.1` and `gatsby@4.25.7` which mitigates the issue. ### Workarounds As stated above, by default `gatsby develop` is only exposed to the localhost `127.0.0.1`. For those using the develop server in the default configuration no risk is posed. If other ranges are required, preventing the develop server from being exposed to untrusted interfaces or IP address ranges would mitigate the risk from this vulnerability. We encourage projects to upgrade to the latest major release branch for all Gatsby plugins to ensure the latest security updates and bug fixes are received in a timely manner. ### Credits We would like to thank Maxwell Garrett of Assetnote for bringing the `__file-code-frame` issue to our attention. ### For more information Email us at [security@gatsbyjs.com](mailto:security@gatsbyjs.com).

CVE-2023-34238 Affected Gatsby Versions

2 component(s)
Fixed Versions:
4.25.75.9.1
Product / Package Ecosystem Affected Versions Fixed Version
gatsby
npm
< 4.25.7
4.25.7
gatsby
npm
≥ 5.0.0
< 5.9.1
5.9.1

References

Frequently Asked Questions

What is CVE-2023-34238?
CVE-2023-34238 is a security vulnerability in Gatsby involving Gatsby develop server has Local File Inclusion vulnerability under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Gatsby versions are affected?
Affected versions include releases prior to 4.25.7, 5.9.1 across affected packages: gatsby.
What version fixes CVE-2023-34238?
Upgrading to 4.25.7, 5.9.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is gatsby affected?
Yes, gatsby is affected in releases prior to 4.25.7, 5.9.1. Upgrade your dependency to 4.25.7, 5.9.1 or later.
What is the CVSS score of CVE-2023-34238?
CVE-2023-34238 has a CVSS v3.1 base score of 4.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:N.
What CWE is associated with CVE-2023-34238?
CVE-2023-34238 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-34238?
Run the dependency tree command: 'npm ls gatsby'. 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-c6f8-8r25-c4gc",
  "modified" : "2023-06-09T22:52:01Z",
  "published" : "2023-06-09T22:52:01Z",
  "aliases" : [ "CVE-2023-34238" ],
  "summary" : "Gatsby develop server has Local File Inclusion vulnerability",
  "details" : "### Impact\n\nThe Gatsby framework prior to versions 4.25.7 and 5.9.1 contain a Local File Inclusion vulnerability in the `__file-code-frame` and `__original-stack-frame` paths, exposed when running the Gatsby develop server (`gatsby develop`).\n\nThe following steps can be used to reproduce the vulnerability:\n\n```\n# Create a new Gatsby project\n$ npm init gatsby\n$ cd my-gatsby-site\n\n# Start the Gatsby develop server\n$ gatsby develop\n\n# Execute the Local File Inclusion vulnerability in __file-code-frame\n$ curl \"http://127.0.0.1:8000/__file-code-frame?filePath=/etc/passwd&lineNumber=1\"\n\n# Execute the Local File Inclusion vulnerability in __original-stack-frame\n$ curl \"http://127.0.0.1:8000/__original-stack-frame?moduleId=/etc/hosts&lineNumber=1&skipSourceMap=1\"\n```\n\nIt should be noted that by default `gatsby develop` is only accessible via the localhost `127.0.0.1`, and one would need to intentionally expose the server to other interfaces to exploit this vulnerability by using server options such as `--host 0.0.0.0`, `-H 0.0.0.0`, or the `GATSBY_HOST=0.0.0.0` environment variable.\n\n\n### Patches\n\nA patch has been introduced in `gatsby@5.9.1` and `gatsby@4.25.7` which mitigates the issue.\n\n\n### Workarounds\n\nAs stated above, by default `gatsby develop` is only exposed to the localhost `127.0.0.1`.  For those using the develop server in the default configuration no risk is posed.  If other ranges are required, preventing the develop server from being exposed to untrusted interfaces or IP address ranges would mitigate the risk from this vulnerability.\n\nWe encourage projects to upgrade to the latest major release branch for all Gatsby plugins to ensure the latest security updates and bug fixes are received in a timely manner.\n\n\n### Credits\n\nWe would like to thank Maxwell Garrett of Assetnote for bringing the `__file-code-frame` issue to our attention.\n\n\n### For more information\n\nEmail us at [security@gatsbyjs.com](mailto:security@gatsbyjs.com).",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "gatsby"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.25.7"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 4.25.6"
    }
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "gatsby"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "5.0.0"
      }, {
        "fixed" : "5.9.1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 5.9.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/gatsbyjs/gatsby/security/advisories/GHSA-c6f8-8r25-c4gc"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-34238"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gatsbyjs/gatsby/commit/ae5a654eb346b2e7a9d341b809b2f82d34c0f17c"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gatsbyjs/gatsby/commit/fc22f4ba3ad7ca5fb3592f38f4f0ca8ae60b4bf7"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/gatsbyjs/gatsby"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-06-09T22:52:01Z",
    "nvd_published_at" : "2023-06-08T00:15:09Z"
  }
}