esbuild enables any website to send any requests to the development server and read the response #3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
⚠️
dependabot-gitlabhas detected security vulnerability foresbuildin path:/, manifest_file:/package.jsonbut was unable to update it! ⚠️GHSA-67mh-4wv8-2f99Description
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.github.com/evanw/esbuild@df815ac27b/pkg/api/serve_other.go (L121)github.com/evanw/esbuild@df815ac27b/pkg/api/serve_other.go (L363)Attack scenario:
http://malicious.example.com).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.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
/index.html: normally you have a script tag here/assets: it's common to have aassetsdirectory when you have JS files and CSS files in a different directory and the directory listing feature tells the attacker the list of files/esbuildSSE 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)))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
npm inpm run watchfetch('http://127.0.0.1:8000/app.js').then(r => r.text()).then(content => console.log(content))in a different website's dev tools.Impact
Users using the serve feature may get the source code stolen by malicious websites.
References
github.com/evanw/esbuild@de85afd65esee https://github.com/vuejs/vitepress/issues/5073