[Security] Bump esbuild, vitest and @vitejs/plugin-react
Bumps esbuild to 0.25.4 and updates ancestor dependencies esbuild, vitest and @vitejs/plugin-react. These dependencies need to be updated together.
Updates esbuild from 0.21.5 to 0.25.4 This update includes a security fix.
Vulnerabilities fixed
esbuild enables any website to send any requests to the development server and read the response
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:
- The attacker serves a malicious web page (
http://malicious.example.com).- The user accesses the malicious web page.
- 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.- 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
... (truncated)
Patched versions: 0.25.0 Affected versions: <= 0.24.2
Release notes
Sourced from esbuild's releases.
v0.25.4
Add simple support for CORS to esbuild's development server (#4125)
Starting with version 0.25.0, esbuild's development server is no longer configured to serve cross-origin requests. This was a deliberate change to prevent any website you visit from accessing your running esbuild development server. However, this change prevented (by design) certain use cases such as "debugging in production" by having your production website load code from
localhostwhere the esbuild development server is running.To enable this use case, esbuild is adding a feature to allow Cross-Origin Resource Sharing (a.k.a. CORS) for simple requests. Specifically, passing your origin to the new
corsoption will now set theAccess-Control-Allow-Originresponse header when the request has a matchingOriginheader. Note that this currently only works for requests that don't send a preflightOPTIONSrequest, as esbuild's development server doesn't currently supportOPTIONSrequests.Some examples:
CLI:
esbuild --servedir=. --cors-origin=https://example.comJS:
const ctx = await esbuild.context({}) await ctx.serve({ servedir: '.', cors: { origin: 'https://example.com', }, })Go:
ctx, _ := api.Context(api.BuildOptions{}) ctx.Serve(api.ServeOptions{ Servedir: ".", CORS: api.CORSOptions{ Origin: []string{"https://example.com"}, }, })The special origin
*can be used to allow any origin to access esbuild's development server. Note that this means any website you visit will be able to read everything served by esbuild.Pass through invalid URLs in source maps unmodified (#4169)
This fixes a regression in version 0.25.0 where
sourcesin source maps that form invalid URLs were not being passed through to the output. Version 0.25.0 changed the interpretation ofsourcesfrom file paths to URLs, which means that URL parsing can now fail. Previously URLs that couldn't be parsed were replaced with the empty string. With this release, invalid URLs insourcesshould now be passed through unmodified.Handle exports named
__proto__in ES modules (#4162, #4163)In JavaScript, the special property name
__proto__sets the prototype when used inside an object literal. Previously esbuild's ESM-to-CommonJS conversion didn't special-case the property name of exports named__proto__so the exported getter accidentally became the prototype of the object literal. It's unclear what this affects, if anything, but it's better practice to avoid this by using a computed property name in this case.This fix was contributed by
@magic-akari.
... (truncated)
Changelog
Sourced from esbuild's changelog.
Changelog: 2024
This changelog documents all esbuild versions published in the year 2024 (versions 0.19.12 through 0.24.2).
0.24.2
Fix regression with
--defineandimport.meta(#4010, #4012, #4013)The previous change in version 0.24.1 to use a more expression-like parser for
definevalues to allow quoted property names introduced a regression that removed the ability to use--define:import.meta=.... Even thoughimportis normally a keyword that can't be used as an identifier, ES modules special-case theimport.metaexpression to behave like an identifier anyway. This change fixes the regression.This fix was contributed by
@sapphi-red.0.24.1
Allow
es2024as a target intsconfig.json(#4004)TypeScript recently added
es2024as a compilation target, so esbuild now supports this in thetargetfield oftsconfig.jsonfiles, such as in the following configuration file:{ "compilerOptions": { "target": "ES2024" } }As a reminder, the only thing that esbuild uses this field for is determining whether or not to use legacy TypeScript behavior for class fields. You can read more in the documentation.
This fix was contributed by
@billyjanitsch.Allow automatic semicolon insertion after
get/setThis change fixes a grammar bug in the parser that incorrectly treated the following code as a syntax error:
class Foo { get *x() {} set *y() {} }The above code will be considered valid starting with this release. This change to esbuild follows a similar change to TypeScript which will allow this syntax starting with TypeScript 5.7.
Allow quoted property names in
--defineand--pure(#4008)The
defineandpureAPI options now accept identifier expressions containing quoted property names. Previously all identifiers in the identifier expression had to be bare identifiers. This change now makes--defineand--pureconsistent with--global-name, which already supported quoted property names. For example, the following is now possible:
... (truncated)
Commits
-
218d29epublish 0.25.4 to npm -
e66cd0bdev server: simple support for CORS requests (#4171) -
8bf3368js api: validate some options as arrays of strings -
1e7375ajs api: simplify comma-separated array validation -
5f5964drelease notes for #4163 -
adb5284fix: handle__proto__as a computed property in exports and add tests for s... -
0aa9f7bfix #4169: keep invalid source map URLs unmodified -
5959289add additional guards for #4114 when using:is() -
677910bpublish 0.25.3 to npm -
a41040efix #4110: support custom non-IPhostvalues - Additional commits viewable in compare view
Updates vitest from 2.1.1 to 3.1.3
Release notes
Sourced from vitest's releases.
v3.1.3
🐞 Bug Fixes
- Correctly resolve vitest import if
inline: trueis set - by@sheremet-vain vitest-dev/vitest#7856 (a83f3)- Fix fixture parsing with lowered async with esbuild 0.25.3 - by
@hi-ogawain vitest-dev/vitest#7921 (c5c85)- Remove event-catcher code - by
@sheremet-vain vitest-dev/vitest#7898 (deb1b)- Reset mocks on test retry/repeat - by
@sheremet-vain vitest-dev/vitest#7897 (2fa76)- Ignore failures on writeToCache - by
@orgadsin vitest-dev/vitest#7893 (8c7f7)- browser: Correctly inherit CLI options - by
@sheremet-vain vitest-dev/vitest#7858 (03660)- deps: Update all non-major dependencies - in vitest-dev/vitest#7867 (67ef7)
- reporters:
--merge-reportsto show each total run times - by@AriPerkkioin vitest-dev/vitest#7877 (d613b)View changes on GitHub
v3.1.2
🐞 Bug Fixes
- Add global
chaivariable invitest/globals(fix: #7474) - by@Jay-Kariain vitest-dev/vitest#7771 and vitest-dev/vitest#7474 (d9297)- Prevent modifying
test.excludewhen same object passed incoverage.exclude- by@AriPerkkioin vitest-dev/vitest#7774 (c3751)- Fix already hoisted mock - by
@hi-ogawain vitest-dev/vitest#7815 (773b1)- Fix test.scoped inheritance - by
@hi-ogawain vitest-dev/vitest#7814 (db6c3)- Remove pointer-events-none after resizing the left panel - by
@alexprudhommein vitest-dev/vitest#7811 (a7e77)- Default to run mode when stdin is not a TTY - by
@kentonv,@hi-ogawaand@sheremet-vain vitest-dev/vitest#7673 (6358f)- Use happy-dom/jsdom types for
envionmentOptions- by@hi-ogawain vitest-dev/vitest#7795 (67430)- browser:
- Fix transform error before browser server initialization - by
@hi-ogawain vitest-dev/vitest#7783 (5f762)- Fix mocking from outside of root - by
@hi-ogawain vitest-dev/vitest#7789 (03f55)- Scale iframe for non ui case - by
@hi-ogawain vitest-dev/vitest#6512 (c3374)- coverage:
awaitprofiler calls - by@AriPerkkioin vitest-dev/vitest#7763 (795a6)- Expose profiling timers - by
@AriPerkkioin vitest-dev/vitest#7820 (5652b)- deps:
- Update all non-major dependencies - in vitest-dev/vitest#7765 (7c3df)
- Update all non-major dependencies - in vitest-dev/vitest#7831 (15701)
- runner:
- Correctly call test hooks and teardown functions - by
@sheremet-vain vitest-dev/vitest#7775 (3c00c)- Show stacktrace on test timeout error - by
@hi-ogawain vitest-dev/vitest#7799 (df33b)- ui:
- Load panel sizes from storage on initial load - by
@userquinin vitest-dev/vitest#7265 (6555d)- vite-node:
- Named export should overwrite export all - by
@hi-ogawain vitest-dev/vitest#7846 (5ba0d)- Add ERR_MODULE_NOT_FOUND code error if module cannot be loaded - by
@sheremet-vain vitest-dev/vitest#7776 (f9eac)
🏎️ Performance
- browser: Improve browser parallelisation - by
@sheremet-vain vitest-dev/vitest#7665 (816a5)View changes on GitHub
v3.1.1
... (truncated)
Commits
-
6e8d937chore: release v3.1.3 -
8c7f75afix: ignore failures on writeToCache (#7893) -
d613b81fix(reporters):--merge-reportsto show each total run times (#7877) -
2fa763afix: reset mocks on test retry/repeat (#7897) -
573cb16ci: fix flaky browser tests (#7887) -
03660f9fix(browser): correctly inherit CLI options (#7858) -
a83f3bffix: correctly resolve vitest import ifinline: trueis set (#7856) -
5a0afd1chore: release v3.1.2 -
b70a6f1chore(deps): unbundle tinyglobby and update (#7864) -
f9eacbcfix(vite-node): add ERR_MODULE_NOT_FOUND code error if module cannot be loade... - Additional commits viewable in compare view
Updates @vitejs/plugin-react from 4.3.1 to 4.4.1
Release notes
Sourced from @vitejs/plugin-react's releases.
plugin-react@4.4.1
Fix type issue when using
moduleResolution: "node"in tsconfig #462plugin-react@4.4.0
Make compatible with rolldown-vite
This plugin is now compatible with rolldown-powered version of Vite. Note that currently the
__sourceproperty value position might be incorrect. This will be fixed in the near future.plugin-react@4.4.0-beta.2
Add
reactRefreshHostoptionAdd
reactRefreshHostoption to set a React Fast Refresh runtime URL prefix. This is useful in a module federation context to enable HMR by specifying the host application URL in the Vite config of a remote application. See full discussion here: module-federation/vite#183export default defineConfig({ plugins: [react({ reactRefreshHost: 'http://localhost:3000' })], })plugin-react@4.4.0-beta.1
No release notes provided.
plugin-react@4.3.4
Add Vite 6 to peerDependencies range
Vite 6 is highly backward compatible, not much to add!
Force Babel to output spec compliant import attributes #386
The default was an old spec (
with type: "json"). We now enforce spec compliant (with { type: "json" })plugin-react@4.3.3
React Compiler runtimeModule option removed
React Compiler was updated to accept a
targetoption andruntimeModulewas removed. vite-plugin-react will still detectruntimeModulefor backwards compatibility.When using a custom
runtimeModuleortarget !== '19', the plugin will not try to pre-optimizereact/compiler-runtimedependency.The react-compiler-runtime is now available on npm can be used instead of the local shim for people using the compiler with React < 19.
Here is the configuration to use the compiler with React 18 and correct source maps in development:
npm install babel-plugin-react-compiler react-compiler-runtime @babel/plugin-transform-react-jsx-development</tr></table>
... (truncated)
Changelog
Sourced from @vitejs/plugin-react's changelog.
4.4.1 (2025-04-19)
Fix type issue when using
moduleResolution: "node"in tsconfig #4624.4.0 (2025-04-15)
Make compatible with rolldown-vite
This plugin is now compatible with rolldown-powered version of Vite. Note that currently the
__sourceproperty value position might be incorrect. This will be fixed in the near future.4.4.0-beta.2 (2025-04-15)
Add
reactRefreshHostoptionAdd
reactRefreshHostoption to set a React Fast Refresh runtime URL prefix. This is useful in a module federation context to enable HMR by specifying the host application URL in the Vite config of a remote application. See full discussion here: module-federation/vite#183export default defineConfig({ plugins: [react({ reactRefreshHost: 'http://localhost:3000' })], })4.4.0-beta.1 (2025-04-09)
4.4.0-beta.0 (2025-04-09)
4.3.4 (2024-11-26)
Add Vite 6 to peerDependencies range
Vite 6 is highly backward compatible, not much to add!
Force Babel to output spec compliant import attributes #386
The default was an old spec (
with type: "json"). We now enforce spec compliant (with { type: "json" })4.3.3 (2024-10-19)
React Compiler runtimeModule option removed
React Compiler was updated to accept a
targetoption andruntimeModulewas removed. vite-plugin-react will still detectruntimeModulefor backwards compatibility.When using a custom
runtimeModuleortarget !== '19', the plugin will not try to pre-optimizereact/compiler-runtimedependency.The react-compiler-runtime is now available on npm can be used instead of the local shim for people using the compiler with React < 19.
Here is the configuration to use the compiler with React 18 and correct source maps in development:
... (truncated)
Commits
-
57cc398release: plugin-react@4.4.1 -
a62bdd6fix(react): fix package.jsontypes(#462) -
8beda4frelease: plugin-react@4.4.0 -
fffe4adfeat: add support for rolldown-vite (#451) -
c197fd9release: plugin-react@4.4.0-beta.2 -
bd1a1adfix(deps): update all non-major dependencies (#392) -
87f7fddfeat: addreactRefreshHostoption to support module federation HMR (#420) -
da01d56release: plugin-react@4.4.0-beta.1 -
9b1b510chore: fix refresh runtime path in dev (#444) -
8258442release: plugin-react@4.4.0-beta.0 - Additional commits viewable in compare view