GHSA-67mh-4wv8-2f99: Esbuild Esbuild Enables Any Website To Vulnerability

MODERATE
CVSS 5.3
CWE-346
Published
Advisory Summary

GHSA-67mh-4wv8-2f99 is a MODERATE (CVSS 5.3) esbuild enables any website to vulnerability (CWE-346: Origin Validation Error) affecting Esbuild libraries in the npm ecosystem. The issue involves esbuild enables any website to send any requests to the development server and read the response. Remediation is available by upgrading affected packages to version 0.25.0.

GHSA-67mh-4wv8-2f99 at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-67mh-4wv8-2f99
Severity MODERATE
CVSS v3.1 Base Score 5.3
CWE Classification CWE-346: Origin Validation Error
Affected Product Esbuild
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 5.3

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

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

How to Fix GHSA-67mh-4wv8-2f99

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.25.0
npm install esbuild@0.25.0
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-67mh-4wv8-2f99, 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.25.0), 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-346: Origin Validation Error, where the product does not properly verify that the source of data or communication is valid. 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 esbuild allows any websites to send any request to the development server and read the response due to default CORS settings. ### Details esbuild sets `Access-Control-Allow-Origin: *` header to all requests, including the SSE connection, which allows any websites to send any request to the development server and read the response. https://github.com/evanw/esbuild/blob/df815ac27b84f8b34374c9182a93c94718f8a630/pkg/api/serve_other.go#L121 https://github.com/evanw/esbuild/blob/df815ac27b84f8b34374c9182a93c94718f8a630/pkg/api/serve_other.go#L363 **Attack scenario**: 1. The attacker serves a malicious web page (`http://malicious.example.com`). 1. The user accesses the malicious web page. 1. The attacker sends a `fetch('http://127.0.0.1:8000/main.js')` request by JS in that malicious web page. This request is normally blocked by same-origin policy, but that's not the case for the reasons above. 1. The attacker gets the content of `http://127.0.0.1:8000/main.js`. In this scenario, I assumed that the attacker knows the URL of the bundle output file name. But the attacker can also get that information by - Fetching `/index.html`: normally you have a script tag here - Fetching `/assets`: it's common to have a `assets` directory when you have JS files and CSS files in a different directory and the directory listing feature tells the attacker the list of files - Connecting `/esbuild` SSE endpoint: the SSE endpoint sends the URL path of the changed files when the file is changed (`new EventSource('/esbuild').addEventListener('change', e => console.log(e.type, e.data))`) - Fetching URLs in the known file: once the attacker knows one file, the attacker can know the URLs imported from that file The scenario above fetches the compiled content, but if the victim has the source map option enabled, the attacker can also get the non-compiled content by fetching the source map file. ### PoC 1. Download [reproduction.zip](https://github.com/user-attachments/files/18561484/reproduction.zip) 2. Extract it and move to that directory 1. Run `npm i` 1. Run `npm run watch` 1. Run `fetch('http://127.0.0.1:8000/app.js').then(r => r.text()).then(content => console.log(content))` in a different website's dev tools. ![image](https://github.com/user-attachments/assets/08fc2e4d-e1ec-44ca-b0ea-78a73c3c40e9) ### Impact Users using the serve feature may get the source code stolen by malicious websites.

GHSA-67mh-4wv8-2f99 Affected Esbuild Versions

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

References

Frequently Asked Questions

What is GHSA-67mh-4wv8-2f99?
GHSA-67mh-4wv8-2f99 is a security vulnerability in Esbuild involving esbuild enables any website to send any requests to the development server and read the response under CWE-346: Origin Validation Error.
Which Esbuild versions are affected?
Affected versions include releases prior to 0.25.0 across affected packages: esbuild.
What version fixes GHSA-67mh-4wv8-2f99?
Upgrading to 0.25.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is esbuild affected?
Yes, esbuild is affected in releases prior to 0.25.0. Upgrade your dependency to 0.25.0 or later.
What is the CVSS score of GHSA-67mh-4wv8-2f99?
GHSA-67mh-4wv8-2f99 has a CVSS v3.1 base score of 5.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:N/A:N.
What CWE is associated with GHSA-67mh-4wv8-2f99?
GHSA-67mh-4wv8-2f99 is classified under CWE-346: Origin Validation Error (The product does not properly verify that the source of data or communication is valid.).
How can I check npm dependencies for GHSA-67mh-4wv8-2f99?
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-67mh-4wv8-2f99",
  "modified" : "2025-02-10T17:48:08Z",
  "published" : "2025-02-10T17:48:07Z",
  "aliases" : [ ],
  "summary" : "esbuild enables any website to send any requests to the development server and read the response",
  "details" : "### Summary\n\nesbuild allows any websites to send any request to the development server and read the response due to default CORS settings.\n\n### Details\n\nesbuild sets `Access-Control-Allow-Origin: *` header to all requests, including the SSE connection, which allows any websites to send any request to the development server and read the response.\n\nhttps://github.com/evanw/esbuild/blob/df815ac27b84f8b34374c9182a93c94718f8a630/pkg/api/serve_other.go#L121\nhttps://github.com/evanw/esbuild/blob/df815ac27b84f8b34374c9182a93c94718f8a630/pkg/api/serve_other.go#L363\n\n**Attack scenario**:\n\n1. The attacker serves a malicious web page (`http://malicious.example.com`).\n1. The user accesses the malicious web page.\n1. The attacker sends a `fetch('http://127.0.0.1:8000/main.js')` request by JS in that malicious web page. This request is normally blocked by same-origin policy, but that's not the case for the reasons above.\n1. The attacker gets the content of `http://127.0.0.1:8000/main.js`.\n\nIn this scenario, I assumed that the attacker knows the URL of the bundle output file name. But the attacker can also get that information by\n\n- Fetching `/index.html`: normally you have a script tag here\n- Fetching `/assets`: it's common to have a `assets` directory when you have JS files and CSS files in a different directory and the directory listing feature tells the attacker the list of files\n- Connecting `/esbuild` SSE endpoint: the SSE endpoint sends the URL path of the changed files when the file is changed (`new EventSource('/esbuild').addEventListener('change', e => console.log(e.type, e.data))`)\n- Fetching URLs in the known file: once the attacker knows one file, the attacker can know the URLs imported from that file\n\nThe scenario above fetches the compiled content, but if the victim has the source map option enabled, the attacker can also get the non-compiled content by fetching the source map file.\n\n### PoC\n\n1. Download [reproduction.zip](https://github.com/user-attachments/files/18561484/reproduction.zip)\n2. Extract it and move to that directory\n1. Run `npm i`\n1. Run `npm run watch`\n1. Run `fetch('http://127.0.0.1:8000/app.js').then(r => r.text()).then(content => console.log(content))` in a different website's dev tools.\n\n![image](https://github.com/user-attachments/assets/08fc2e4d-e1ec-44ca-b0ea-78a73c3c40e9)\n\n### Impact\n\nUsers using the serve feature may get the source code stolen by malicious websites.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "esbuild"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.25.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 0.24.2"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/evanw/esbuild/security/advisories/GHSA-67mh-4wv8-2f99"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/evanw/esbuild/commit/de85afd65edec9ebc44a11e245fd9e9a2e99760d"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/evanw/esbuild"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-346" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-02-10T17:48:07Z",
    "nvd_published_at" : null
  }
}