GHSA-g7r4-m6w7-qqqr: Esbuild Esbuild Allows Arbitrary File Read Vulnerability

LOW
CVSS 2.5
CWE-22
Published
Advisory Summary

GHSA-g7r4-m6w7-qqqr is a LOW (CVSS 2.5) esbuild allows arbitrary file read vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Esbuild libraries in the npm ecosystem. The issue involves esbuild allows arbitrary file read when running the development server on windows. Remediation is available by upgrading affected packages to version 0.28.1.

GHSA-g7r4-m6w7-qqqr at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-g7r4-m6w7-qqqr
Severity LOW
CVSS v3.1 Base Score 2.5
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Esbuild
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 2.5

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

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

How to Fix GHSA-g7r4-m6w7-qqqr

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

esbuild fixed: 0.28.1
npm install esbuild@0.28.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 esbuild

How to Check if You Are Affected

To determine whether your Node.js application is affected by GHSA-g7r4-m6w7-qqqr, inspect your project dependencies using npm:

npm ls esbuild

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

Note: The npm ls esbuild 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 Esbuild, 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

### Summary The development server contains a path traversal vulnerability on Windows when serving files from `servedir`. Due to the use of `path.Clean()` (which only normalizes forward-slash `/` separators) instead of a Windows-aware path normalization function, it is possible to craft requests using backslashes (`\`) that bypass the intended directory containment logic. An attacker can escape the configured `servedir` root and access arbitrary files on the filesystem. This issue affects Windows environments only. ### Details The request path is sanitized using: ```go // https://github.com/evanw/esbuild/blob/v0.27.3/pkg/api/serve_other.go#L165 queryPath := path.Clean(req.URL.Path)[1:] ``` However: - `path.Clean()` is POSIX-style and only understands `/` (docs: `https://pkg.go.dev/path#Clean`) - On Windows, `\` is a valid path separator - `path.Clean()` does not treat `\` as a separator Later, the server constructs the absolute path: ```go // https://github.com/evanw/esbuild/blob/v0.27.3/pkg/api/serve_other.go#L221 absPath := h.fs.Join(h.servedir, queryPath) ``` If `queryPath` contains sequences such as: ``` ..\..\..\..\..\..\..\Windows\system.ini ``` `path.Clean()` will not normalize them, but the Windows filesystem will interpret `\` as directory separators when resolving `absPath`. Because the implementation does not verify that the final resolved path remains within `servedir`, it allows directory traversal outside the intended root directory. ### Vulnerable Code ```go // https://github.com/evanw/esbuild/blob/v0.27.3/pkg/api/serve_other.go#L165 queryPath := path.Clean(req.URL.Path)[1:] .... // Check for a file in the "servedir" directory if h.servedir != "" && kind != fs.FileEntry { absPath := h.fs.Join(h.servedir, queryPath) if absDir := h.fs.Dir(absPath); absDir != absPath { if entries, err, _ := h.fs.ReadDirectory(absDir); err == nil { if entry, _ := entries.Get(h.fs.Base(absPath)); entry != nil && entry.Kind(h.fs) == fs.FileEntry { .... ``` ### Steps to reproduce ``` npm install --save-exact --save-dev esbuild echo "console.log(1)" > app.js .\node_modules\.bin\esbuild --version 0.27.3 .\node_modules\.bin\esbuild app.js --bundle --outdir=www --servedir=www --watch curl -i --path-as-is "http://localhost:8000/..\..\..\..\..\..\..\Windows\system.ini" <content of Windows\system.ini> ``` ### Impact - Arbitrary file read on Windows - Exposure of sensitive files

GHSA-g7r4-m6w7-qqqr Affected Esbuild Versions

1 component(s)
Fixed Versions:
0.28.1
Product / Package Ecosystem Affected Versions Fixed Version
esbuild
npm
≥ 0.27.3
< 0.28.1
0.28.1

References

Frequently Asked Questions

What is GHSA-g7r4-m6w7-qqqr?
GHSA-g7r4-m6w7-qqqr is a security vulnerability in Esbuild involving esbuild allows arbitrary file read when running the development server on Windows under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Esbuild versions are affected?
Affected versions include releases prior to 0.28.1 across affected packages: esbuild.
What version fixes GHSA-g7r4-m6w7-qqqr?
Upgrading to 0.28.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is esbuild affected?
Yes, esbuild is affected in releases prior to 0.28.1. Upgrade your dependency to 0.28.1 or later.
What is the CVSS score of GHSA-g7r4-m6w7-qqqr?
GHSA-g7r4-m6w7-qqqr has a CVSS v3.1 base score of 2.5 (LOW) with vector string CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:L/A:N.
What CWE is associated with GHSA-g7r4-m6w7-qqqr?
GHSA-g7r4-m6w7-qqqr 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 GHSA-g7r4-m6w7-qqqr?
Run the dependency tree command: 'npm ls esbuild'. 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-g7r4-m6w7-qqqr",
  "modified" : "2026-06-12T20:08:53Z",
  "published" : "2026-06-12T20:08:53Z",
  "aliases" : [ ],
  "summary" : "esbuild allows arbitrary file read when running the development server on Windows",
  "details" : "### Summary\n\nThe development server contains a path traversal vulnerability on Windows when serving files from `servedir`.\n\nDue to the use of `path.Clean()` (which only normalizes forward-slash `/` separators) instead of a Windows-aware path normalization function, it is possible to craft requests using backslashes (`\\`) that bypass the intended directory containment logic. An attacker can escape the configured `servedir` root and access arbitrary files on the filesystem.\nThis issue affects Windows environments only.\n\n### Details\n\nThe request path is sanitized using:\n```go\n// https://github.com/evanw/esbuild/blob/v0.27.3/pkg/api/serve_other.go#L165\nqueryPath := path.Clean(req.URL.Path)[1:]\n```\n\n\nHowever:\n- `path.Clean()` is POSIX-style and only understands `/` (docs: `https://pkg.go.dev/path#Clean`)\n- On Windows, `\\` is a valid path separator\n- `path.Clean()` does not treat `\\` as a separator\n\nLater, the server constructs the absolute path:\n```go\n// https://github.com/evanw/esbuild/blob/v0.27.3/pkg/api/serve_other.go#L221\nabsPath := h.fs.Join(h.servedir, queryPath)\n```\n\nIf `queryPath` contains sequences such as:\n```\n..\\..\\..\\..\\..\\..\\..\\Windows\\system.ini\n```\n\n`path.Clean()` will not normalize them, but the Windows filesystem will interpret `\\` as directory separators when resolving `absPath`.\nBecause the implementation does not verify that the final resolved path remains within `servedir`, it allows directory traversal outside the intended root directory.\n### Vulnerable Code\n\n```go\n// https://github.com/evanw/esbuild/blob/v0.27.3/pkg/api/serve_other.go#L165\n\tqueryPath := path.Clean(req.URL.Path)[1:]\n\t....\n\t// Check for a file in the \"servedir\" directory\n\tif h.servedir != \"\" && kind != fs.FileEntry {\n\t\tabsPath := h.fs.Join(h.servedir, queryPath)\n\t\tif absDir := h.fs.Dir(absPath); absDir != absPath {\n\t\t\tif entries, err, _ := h.fs.ReadDirectory(absDir); err == nil {\n\t\t\t\tif entry, _ := entries.Get(h.fs.Base(absPath)); entry != nil && entry.Kind(h.fs) == fs.FileEntry {\n\t....\t\t\t\t\n```\n\n\n### Steps to reproduce\n\n```\nnpm install --save-exact --save-dev esbuild\n\necho \"console.log(1)\" > app.js\n\n.\\node_modules\\.bin\\esbuild --version\n0.27.3\n\n.\\node_modules\\.bin\\esbuild app.js --bundle --outdir=www --servedir=www --watch\n\ncurl -i --path-as-is \"http://localhost:8000/..\\..\\..\\..\\..\\..\\..\\Windows\\system.ini\"\n<content of Windows\\system.ini>\n```\n\n\n### Impact\n\n- Arbitrary file read on Windows\n- Exposure of sensitive files",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "esbuild"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.27.3"
      }, {
        "fixed" : "0.28.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/evanw/esbuild/security/advisories/GHSA-g7r4-m6w7-qqqr"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/evanw/esbuild"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/evanw/esbuild/releases/tag/v0.28.1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-06-12T20:08:53Z",
    "nvd_published_at" : null
  }
}