# GHSA-g7r4-m6w7-qqqr: esbuild allows arbitrary file read when running the development server on Windows

> Attackers can read arbitrary files on Windows systems by exploiting path traversal in the esbuild development server when servedir is configured.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 12 Jun 2026

## What is GHSA-g7r4-m6w7-qqqr?

GHSA-g7r4-m6w7-qqqr is a path traversal vulnerability in esbuild, published on 12 Jun 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

### 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

## Which versions are affected by GHSA-g7r4-m6w7-qqqr?

2 open source packages ship an affected version, including esbuild.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `esbuild` | npm | From 0.27.3 | 0.28.1 |
| `esbuild` | npm | From 0.27.3 | 0.28.1 |

## How do I fix GHSA-g7r4-m6w7-qqqr?

Upgrade esbuild to 0.28.1 or later.

## Is GHSA-g7r4-m6w7-qqqr being exploited?

There is no known exploitation of GHSA-g7r4-m6w7-qqqr in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-g7r4-m6w7-qqqr and fix it if it is affected.

What it is: GHSA-g7r4-m6w7-qqqr is a path traversal vulnerability in esbuild, published on 12 Jun 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of GHSA-g7r4-m6w7-qqqr in the wild and no public exploit code.

Affected packages and fixed versions:
- esbuild (npm): affected from 0.27.3; fixed in 0.28.1
- esbuild (npm): affected from 0.27.3; fixed in 0.28.1

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-g7r4-m6w7-qqqr/ (Markdown: https://insights.sbomify.com/GHSA-g7r4-m6w7-qqqr/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-g7r4-m6w7-qqqr

---
From sbomify Insights: https://insights.sbomify.com/GHSA-g7r4-m6w7-qqqr/
Summaries are generated and may contain mistakes; the official description above is the record.
