Vulnerabilities in pkg:npm/gatsby-plugin-sharp
PACKAGECVE-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.
pkg:npm/gatsby-plugin-sharp
Vulnerability advisories affecting package pkg:npm/gatsby-plugin-sharp. Select an advisory below to view technical details or fixes.
| Advisory ID | CVE / NVD | Severity | Summary |
|---|---|---|---|
| GHSA-h2pm-378c-pcxx | CVE-2023-30548 | MODERATE | Path traversal vulnerability in gatsby-plugin-sharp |
CVE-2023-30548 at a Glance
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).
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.
npm install gatsby-plugin-sharp@5.8.1
npm install gatsby-plugin-sharp@4.25.1
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
CVE-2023-30548 Affected Gatsby plugin sharp Versions
2 component(s)| 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?
Which Gatsby plugin sharp versions are affected?
What version fixes CVE-2023-30548?
Is gatsby-plugin-sharp affected?
What is the CVSS score of CVE-2023-30548?
What CWE is associated with CVE-2023-30548?
How can I check npm dependencies for CVE-2023-30548?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"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"
}
}