CVE-2023-30548: Gatsby plugin sharp Path Traversal Vulnerability

MODERATE
Advisory Identifier: GHSA-h2pm-378c-pcxx
CVSS 4.3
CWE-22
Published
Advisory Summary

CVE-2023-30548 is a MODERATE (CVSS 4.3) path traversal vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Gatsby plugin sharp libraries in the npm ecosystem. The issue involves path traversal vulnerability in gatsby-plugin-sharp. Remediation is available by upgrading affected packages to version 5.8.1, 4.25.1.

CVE-2023-30548 at a Glance

CVE Identifier CVE-2023-30548
GHSA Identifier GHSA-h2pm-378c-pcxx
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 plugin sharp
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-30548

To remediate this vulnerability, upgrade all affected Gatsby plugin sharp 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-plugin-sharp fixed: 5.8.1
npm install gatsby-plugin-sharp@5.8.1
gatsby-plugin-sharp fixed: 4.25.1
npm install gatsby-plugin-sharp@4.25.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-plugin-sharp

How to Check if You Are Affected

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

npm ls gatsby-plugin-sharp

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

Note: The npm ls gatsby-plugin-sharp 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 plugin sharp, 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-plugin-sharp plugin prior to versions 5.8.1 and 4.25.1 contains a path traversal vulnerability exposed when running the Gatsby develop server (`gatsby develop`). The following steps can be used to reproduce the vulnerability: ``` # Create a new Gatsby project, and install gatsby-plugin-sharp $ npm init gatsby $ cd my-gatsby-site $ npm install gatsby-plugin-sharp # Add the plugin to gatsby-config.js module.exports = { plugins: [ { resolve: `gatsby-plugin-sharp`, }, ] } # Start the Gatsby develop server $ gatsby develop # Execute the path traversal vulnerability $ curl "http://127.0.0.1:8000/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/etc/passwd" ``` 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-plugin-sharp@5.8.1` and `gatsby-plugin-sharp@4.25.1` which mitigates the issue by ensuring that included paths remain within the project directory. ### 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 Patrick Rombouts and Bart Veneman [drukwerkdeal.nl] for bringing the issue to our attention. ### For more information Email us at [security@gatsbyjs.com](mailto:security@gatsbyjs.com).

CVE-2023-30548 Affected Gatsby plugin sharp Versions

2 component(s)
Fixed Versions:
5.8.14.25.1
Product / Package Ecosystem Affected Versions Fixed Version
gatsby-plugin-sharp
npm
≥ 5.0.0
< 5.8.1
5.8.1
gatsby-plugin-sharp
npm
< 4.25.1
4.25.1

References

Frequently Asked Questions

What is CVE-2023-30548?
CVE-2023-30548 is a security vulnerability in Gatsby plugin sharp involving Path traversal vulnerability in gatsby-plugin-sharp under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Gatsby plugin sharp versions are affected?
Affected versions include releases prior to 5.8.1, 4.25.1 across affected packages: gatsby-plugin-sharp.
What version fixes CVE-2023-30548?
Upgrading to 5.8.1, 4.25.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is gatsby-plugin-sharp affected?
Yes, gatsby-plugin-sharp is affected in releases prior to 5.8.1, 4.25.1. Upgrade your dependency to 5.8.1, 4.25.1 or later.
What is the CVSS score of CVE-2023-30548?
CVE-2023-30548 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-30548?
CVE-2023-30548 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-30548?
Run the dependency tree command: 'npm ls gatsby-plugin-sharp'. 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-h2pm-378c-pcxx",
  "modified" : "2023-04-20T19:05:34Z",
  "published" : "2023-04-20T19:05:34Z",
  "aliases" : [ "CVE-2023-30548" ],
  "summary" : "Path traversal vulnerability in gatsby-plugin-sharp",
  "details" : "### Impact\n\nThe gatsby-plugin-sharp plugin prior to versions 5.8.1 and 4.25.1 contains a path traversal vulnerability 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, and install gatsby-plugin-sharp\n$ npm init gatsby\n$ cd my-gatsby-site\n$ npm install gatsby-plugin-sharp\n\n\n# Add the plugin to gatsby-config.js\nmodule.exports = {\n  plugins: [\n    {\n      resolve: `gatsby-plugin-sharp`,\n    },\n  ]\n}\n\n# Start the Gatsby develop server\n$ gatsby develop\n\n# Execute the path traversal vulnerability\n$ curl \"http://127.0.0.1:8000/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/etc/passwd\"\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-plugin-sharp@5.8.1` and `gatsby-plugin-sharp@4.25.1` which mitigates the issue by ensuring that included paths remain within the project directory.\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 Patrick Rombouts and Bart Veneman [drukwerkdeal.nl] for bringing the 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-plugin-sharp"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "5.0.0"
      }, {
        "fixed" : "5.8.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "gatsby-plugin-sharp"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.25.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/gatsbyjs/gatsby/security/advisories/GHSA-h2pm-378c-pcxx"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-30548"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gatsbyjs/gatsby/commit/5f442081b227cc0879babb96858f970c4ce94c6b"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gatsbyjs/gatsby/commit/dcf88ed01df2c26e0c93a41e1a2a840076d8247e"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/gatsbyjs/gatsby"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-04-20T19:05:34Z",
    "nvd_published_at" : "2023-04-17T21:15:07Z"
  }
}