Your Dev Server’s WebSocket Is Public Now: Cross-Site WebSocket Hijacking Behind a Tunnel
A tunnel makes your HMR WebSocket public. Learn how Cross-Site WebSocket Hijacking works, why a null Origin matters, and a per-framework fix checklist.

Quick answer
Dev Server WebSocket Hijacking Behind a Tunnel (CSWSH): webhook testing answer
For local webhook testing, run your app locally, expose it with a public HTTPS tunnel, and paste the stable callback URL into the provider dashboard.
How do I test webhooks on localhost?
Start your local server, open a public HTTPS tunnel to that port, configure the provider webhook URL, and inspect events in your local logs.
Why does a stable webhook URL matter?
Stable URLs prevent provider dashboards from needing manual callback updates every time you restart a tunnel.
You ran npm run dev, started a tunnel so a teammate could review your work, and shared the link. The page loads and hot reload works. But the page is not the only thing you published. The hot module replacement (HMR) WebSocket your framework opens in the background is now reachable from the internet too.
That socket was designed for a world where only your own browser could talk to it. Several vulnerabilities from 2025 and 2026 show what happens when that assumption breaks. Next.js, Vite, webpack-dev-server, Mailpit and nginx-ui have all shipped fixes for WebSocket origin-validation problems, and webpack-dev-server’s most recent one landed in October 2026. This guide explains the attack class, what an Origin check really protects against, why a missing or null Origin deserves special attention, and what to do per framework.
What is cross-site WebSocket hijacking (CSWSH)?
Cross-site WebSocket hijacking is the WebSocket version of cross-site request forgery. Browsers do not apply the same-origin policy to WebSocket connections, and they attach the site’s cookies to the handshake request. A page on any origin can therefore try to open a socket to your server. Unless the server checks the handshake itself, the connection succeeds with the victim’s credentials. OWASP’s WebSocket Security Cheat Sheet recommends validating the Origin header on every handshake against an explicit allowlist. It also stresses that page JavaScript cannot override that header, and that wildcards and substring matching are error-prone.
The handshake is an ordinary HTTP GET with Upgrade: websocket. The browser adds an Origin header naming the page that started the connection, and the server decides whether to answer 101 Switching Protocols or refuse. Once the socket is open, the attacker’s script can read and send messages for as long as the tab stays open.
Dev servers add a twist. They usually have no login, so the “credential” being abused is network position: the victim’s browser can reach localhost:5173, and the attacker’s page borrows that reach. Vite’s advisory (CVE-2025-24010, January 2025) says outright that it applied even to people who only ran the dev server locally.
For a dev server, the messages are the problem. Vite’s advisory notes that its socket carries the paths of changed files and the file content around build errors. It also warns that plugins can send arbitrary messages that may include more sensitive data.
Why a tunnel changes the threat model
Without a tunnel, a CSWSH attack needs a specific victim: you, running the server, visiting a malicious page on the same machine. That is real (it is why these CVEs exist), but narrow. A tunnel changes three things:
- Reach. Anyone who learns the public URL can open a connection. They do not need your browser; a script that speaks the WebSocket protocol can connect from anywhere.
- Exposure window. Tunnels can stay up for long stretches, and links get pasted into chats, tickets and screenshots.
- Trust confusion. The dev server was built to trust
localhostand its own hostname. Behind a tunnel, requests arrive with a differentHostandOrigin, so people loosen checks to make the page work. That loosening is where much of the real exposure comes from.
The framework docs reflect this. The Next.js allowedDevOrigins documentation says the dev server already allows localhost, its subdomains and the hostname it was started with, and any other hostname, such as a tunnel used for remote development, needs an explicit entry. Vite’s server.allowedHosts defaults to an empty list, with localhost, *.localhost and all IP addresses allowed implicitly. The Vite docs warn that setting it to true lets any website reach your dev server through DNS rebinding and download your source. (Host-header allowlists are a separate topic; here we stay on the WebSocket upgrade.)
What an Origin check actually blocks
An Origin check answers one question: which web page initiated this browser connection? Because the browser sets the header and page scripts cannot change it, the server can treat it as evidence of the calling page. That makes it effective against exactly one attacker: a malicious web page driving a victim’s browser.
| Threat | Does an Origin check stop it? |
|---|---|
| Malicious website opens a socket via the victim’s browser (CSWSH) | Yes, if the allowlist is strict |
Attacker script or curl connects straight to the public tunnel URL |
No. Non-browser clients can send any Origin, or none |
| Someone opens your tunnel URL in their own browser | Partly. Their page is same-origin, so it passes |
| Stolen or guessed tunnel URL | No. It is a credential-free endpoint |
This is the central lesson for tunnels. An Origin check defends against browsers being used as a confused deputy. It is not authentication. Once your dev server is reachable by raw clients, “we check Origin” is no barrier against a deliberate attacker, because forging the header takes one flag in any HTTP client. webpack-dev-server’s own release notes say as much about its cross-site protections: non-browser clients such as curl are unaffected by them.
It still matters, because it closes the drive-by path: a stranger’s web page cannot silently piggyback on a reviewer’s browser. But it needs a second layer in front (see below). SameSite cookies add defense in depth, since Lax or Strict cookies will not ride along on a cross-site handshake. They do not help if the attacker’s page lives on another subdomain of the same site, though.
Why a missing or null Origin matters
Two special cases cause most real bugs.
A missing Origin. Browsers send Origin on WebSocket handshakes, but command-line tools and native clients do not. Servers often treat a missing header as “not a browser, so no CSWSH risk” and let it through. On a private loopback interface that can be defensible. Behind a tunnel it is a hole, because the missing-header path is exactly the path a direct attacker takes.
Vite shows both sides of this. Its CSWSH fix (6.0.9 and later) verifies a token on handshakes that carry an Origin header, while handshakes without one are let through for non-browser tooling. Then in April 2026, CVE-2026-39363 showed the cost. If a Vite dev server was exposed to the network with --host and its WebSocket was left enabled, a client that connected with no Origin header could invoke a module-fetching call over the socket. Combined with a file:// path and the ?raw suffix, that returned the contents of arbitrary files on the machine. The access checks that protect the HTTP side were not applied on that path. GitHub rates it High (CVSS 4.0: 8.2), and it is fixed in Vite 6.4.2, 7.3.2 and 8.0.5.
Origin: null. The literal string null is what browsers send for opaque origins. MDN lists the common cases: sandboxed iframes without allow-same-origin, data:, file: and blob: documents, and requests that crossed an origin boundary through a redirect. Chrome’s guidance on validating origins adds that two unrelated opaque contexts both serialize to "null", so comparing them as strings falsely equates them, and it recommends rejecting "null" before comparing anything. Chrome’s guide also warns against startsWith and includes checks, since a prefix test passes a hostile domain like app.example.com.attacker.example.
An attacker can manufacture a null origin cheaply. A hostile page loads a sandboxed iframe whose script opens the WebSocket, and the browser sends Origin: null. If your code treats null as “local file, probably me,” that page walks straight in. That is the shape of CVE-2026-27977.
2026 case files
The table summarizes the fixes covered below.
| Project | CVE | Problem | Fixed in |
|---|---|---|---|
| Next.js | CVE-2026-27977 | Origin: null bypassed dev WebSocket protection |
16.1.7 |
| Vite | CVE-2026-39363 | File read over the WebSocket when no Origin is sent |
6.4.2, 7.3.2, 8.0.5 |
| webpack-dev-server | CVE-2026-9595 | Broad ws: true proxy swallowed the HMR socket |
5.2.5 |
| webpack-dev-server | CVE-2026-112085 | Proxied WebSocket upgrades skipped Host/Origin checks | 5.2.7, 6.1.0 |
| Mailpit | CVE-2026-22689, then CVE-2026-67448 | Any origin accepted, then a percent-encoding bypass of the fix | 1.28.2, then 1.30.6 |
| nginx-ui | CVE-2026-34403 | Origin check always returned true | 2.3.5 |
Next.js: Origin: null as a bypass (CVE-2026-27977)
The advisory (GHSA-jcc7-9wpm-mj36), published in March 2026, says that in next dev from 16.0.1 up to but not including 16.1.7, cross-site protection for internal dev endpoints could treat Origin: null as a bypass case, even when allowedDevOrigins was configured. Version 16.1.7 sends null through the same origin-allowance checks as every other origin. It affects development mode only, not next start.
Severity is modest and depends on who scores it. GitHub’s advisory says Moderate, the CVSS 3.1 base score is 5.4, and the CVSS 4.0 score recorded in the CVE entry is 2.3. The lesson outweighs the score: a correctly configured allowlist was undone by one special-case branch. If you cannot upgrade, the advisory says to keep next dev off untrusted networks and to reject Origin: null requests and WebSocket upgrades to internal dev endpoints at a proxy. The CVE description for the affected versions also notes that apps with no allowedDevOrigins set still allowed connections from any origin, so configure it explicitly.
The same bug class hit production code in the same release. CVE-2026-27978 (CVSS 3.1: 4.3) fixed Server Action CSRF validation, which had treated origin: null as if the header were missing. Requests from sandboxed iframes could skip origin verification entirely.
webpack-dev-server: when the proxy swallows or skips the checks (CVE-2026-9595 and CVE-2026-112085)
Two 2026 advisories involve devServer.proxy entries with ws: true.
CVE-2026-9595 (GHSA-mx8g-39q3-5c79, June 2026, CVSS 3.1: 5.3) is not a missing allowlist. When a proxy entry has a broad context such as / and ws: true, it also catches the dev server’s own HMR upgrade and forwards it to your proxy target. That sends the browser’s cookies and Origin header to your backend, skips the dev server’s Host and Origin validation, and leaves the proxy and HMR writing to the same socket. It is fixed in 5.2.5.
CVE-2026-112085 (published October 22, 2026, CVSS 3.1: 8.2 High) is the mirror image. In versions before 5.2.7, and in 6.0.0, a proxy entry configured to forward WebSockets passed non-HMR upgrade requests to the proxy target without validating Host or Origin, so allowedHosts protection did not apply to them. A malicious page visited by a developer could open a cross-origin socket through the dev server and read from and write to the proxied backend, even when the server was bound to loopback. It is fixed in 5.2.7 and 6.1.0.
The maintainers’ workaround for both: scope proxy contexts to specific API paths, and drop ws: true where you do not need it. If you tunnel a webpack project, target 5.2.7 or later (or 6.1.0 or later on the 6.x line).
Earlier fixes are worth knowing too. Version 5.2.1 patched CVE-2025-30360, where any IP-address Origin was always accepted, letting a malicious site served from a bare IP read source code in non-Chromium browsers. Version 5.2.6 added cross-site protection for the state-changing routes /webpack-dev-server/invalidate and /webpack-dev-server/open-editor (it checks Sec-Fetch-Site, falling back to an Origin/Host comparison), so a cross-site page can no longer trigger a rebuild or open a file in your editor. It also made malformed Host and Origin values get handled gracefully.
Vite has a related caveat. Its docs state that Vite does not check the origin of WebSocket requests it proxies. The proxy target is expected to do that, and the rewriteWsOrigin option rewrites the origin and defeats such a check.
Mailpit: a regression of its own fix (CVE-2026-22689, then CVE-2026-67448)
Mailpit, the local email-testing tool, first accepted WebSocket connections from any origin (CVE-2026-22689, CVSS 6.5, fixed in 1.28.2, January 2026). A malicious site could watch events arrive on a developer’s default ws://localhost:8025, including email subjects, sender and recipient details, and mailbox statistics.
The fix later regressed. CVE-2026-67448, published August 20, 2026 (CVSS 6.5), affects 1.29.0 through 1.30.5. The origin middleware checked the raw request URI for the /api/ prefix while Go’s router matched on the percent-decoded path, so /%61pi/events skipped the check and reached the events WebSocket. It is fixed in 1.30.6, and instances protected with --ui-auth-file are not affected, because the encoded path still returns 401 there. A mail inbox is exactly what you should not publish by accident, so put authentication in front of any tunnel that points at it.
nginx-ui: every endpoint said yes (CVE-2026-34403)
Before 2.3.5 (published April 20, 2026), every WebSocket endpoint in nginx-ui used an upgrader whose origin check unconditionally returned true. The advisory also notes that the frontend stored its JWT in a cookie set from JavaScript without HttpOnly or an explicit SameSite attribute. If a logged-in administrator visited an attacker’s page, that page could open authenticated sockets. The listed endpoints leak Nginx metrics, events and cluster node data, and one triggers a binary upgrade. GitHub’s advisory labels it High, and vulnerability databases report CVSS scores of 8.1 to 8.6. It is textbook CSWSH, and “always true” is a classic way to make a demo work that survives into production.
A per-framework checklist
Next.js
- On 16.x, upgrade to 16.1.7 or later.
- Add only your exact tunnel hostname to
allowedDevOrigins. Entries are matched against the Origin’s hostname only, with no scheme or port.*covers exactly one label and**one or more (and only at the start of the pattern), so prefer a specific subdomain over a broad wildcard. - Optionally reject
/_next/webpack-hmrupgrades carryingOrigin: nullat a proxy.
webpack-dev-server
- Upgrade to 5.2.7 or later (6.1.0 or later on 6.x), and check lockfiles, since older scaffolds can pin old versions.
- Replace
/proxy contexts with explicit paths such as/api, and remove unneededws: true.
Vite
- Run a release that includes both the CVE-2025-24010 fixes (6.0.9, 5.4.12, 4.5.6 or newer) and the CVE-2026-39363 fixes (6.4.2, 7.3.2, 8.0.5 or newer).
- Add the tunnel hostname to
server.allowedHostsrather than setting it totrue, and never setserver.corstotrue. If you must expose the server with--host, setserver.ws: falsewhere you do not need HMR. - Remember that a handshake without an
Originheader is treated as non-browser tooling, so allowing your tunnel’s Host means raw clients can still reach the socket. This is another reason to authenticate at the edge.
Mailpit and nginx-ui
- Mailpit 1.30.6 or later, with
--ui-auth-fileif the UI is reachable beyond your machine. nginx-ui 2.3.5 or later, and never an admin panel on a quick tunnel.
Your own ws or Socket.IO server
Verify Origin in the HTTP
upgradeevent before callinghandleUpgrade(OWASP recommends this oververifyClient). Compare against an exact allowlist, never withstartsWithorincludes, and reject absent and"null"values explicitly:const allowed = new Set(["https://my-app.tunnel.example.com"]); server.on("upgrade", (req, socket, head) => { const origin = req.headers.origin; if (!origin || origin === "null" || !allowed.has(origin)) { socket.write("HTTP/1.1 403 Forbidden\r\n\r\n"); return socket.destroy(); } wss.handleUpgrade(req, socket, head, (ws) => wss.emit("connection", ws, req)); });If you already use CSRF tokens, include one in the handshake. OWASP also advises checking authorization on every message, since an open socket should not mean unlimited access.
In Go, never leave
CheckOriginreturningtrue. That one line is the root of both the Mailpit and nginx-ui CVEs.
Put authentication in front of the socket
Because Origin checks do not stop direct clients, the strongest move is to make the tunnel itself demand credentials before any request, including the Upgrade request, reaches your dev server. A password or Basic Auth gate at the tunnel edge means an unauthenticated visitor is refused before your HMR socket sees the handshake. It also covers framework versions you have not patched yet. (InstaTunnel’s pricing page lists password protection and basic auth under its Pro plan; check your own plan before relying on it.)
Treat the gate and the Origin allowlist as two layers, not substitutes. The password stops strangers; the allowlist stops a hostile page from hijacking the session of a reviewer who has already signed in. Share the credential privately, and rotate it when the review ends, because a password pasted into a public ticket is no better than none.
A sensible baseline for any shared dev tunnel: patched framework, exact-hostname allowlist, null and missing Origin rejected where your framework allows it, and a password at the edge.
Test your own setup in two minutes
Run this against your tunnel URL. A secure setup refuses the upgrade instead of answering 101 Switching Protocols. The --http1.1 flag matters because the Upgrade mechanism does not exist in HTTP/2, and --max-time stops curl from hanging on an open socket:
curl -i -N --http1.1 --max-time 5 \
-H "Connection: Upgrade" -H "Upgrade: websocket" \
-H "Sec-WebSocket-Version: 13" \
-H "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==" \
-H "Origin: null" \
https://your-tunnel.example.com/_next/webpack-hmr
Repeat with -H "Origin: https://evil.example" and with the Origin header omitted, using your framework’s real socket path. For Vite, also add -H "Sec-WebSocket-Protocol: vite-hmr". OWASP’s testing list suggests the same three ideas: connect from unauthorized origins, connect without credentials, and check what the server logs. Note that Vite is designed to let the no-Origin variant through for non-browser clients, so a 101 there is expected and is exactly the case the edge password has to cover. If any variant returns 101 and you have no gate in front, an unauthenticated client can talk to your HMR socket. With a password gate in place, all three should fail before reaching the framework, typically with a 401.
One more operational note: ordinary HTTP access logs capture only the upgrade request, not the messages that follow. If you leave a tunnel running, log connection origins and failures so you can see who is knocking.
FAQ
Am I at risk if I never use a tunnel?
In a narrower way, yes. Most of these CVEs were exploitable from a malicious web page against a locally running server. Patch regardless; a tunnel only widens who can try.
Is Origin: null the same as no Origin header?
No. A missing header usually means a non-browser client. A literal null means a browser sent the request from an opaque context. Reject both unless you have a specific reason not to, and know that some frameworks (Vite, for one) deliberately accept the missing case.
Does HTTPS on the tunnel fix this?
No. TLS protects traffic in transit, but a hostile page can open a wss:// connection just as easily. The issue is who may connect, not whether the traffic is encrypted.
The takeaway
Hot reload feels like a harmless convenience, but it is a long-lived, bidirectional channel into your toolchain. When a tunnel makes it public, the only things between that channel and the internet are your framework’s origin checks and whatever you add in front. The recent CVEs show those checks fail in surprising ways: a null special case, a proxy that swallows or skips the upgrade checks, a percent-encoded path, a hard-coded true, a missing header treated as trusted.
Patch the frameworks, allowlist exact hostnames, refuse missing and null origins where you can, and put a password at the edge. Then your tunnel shares what you meant to share: a preview of the page, not a live feed of your source code.
Sources
- GitHub advisory GHSA-jcc7-9wpm-mj36 (Next.js, CVE-2026-27977) and CVE-2026-27977 record
- NVD: CVE-2026-27978 (Next.js Server Actions)
- Next.js docs: allowedDevOrigins
- GHSA-mx8g-39q3-5c79 / CVE-2026-9595 (webpack-dev-server)
- CVE-2026-112085 (webpack-dev-server) and CVE-2025-30360 (webpack-dev-server)
- CVE-2026-67448 (Mailpit) and CVE-2026-22689 (Mailpit)
- CVE-2026-34403 (nginx-ui)
- Vite advisory GHSA-vg6x-rcgg-rjx6 (CVE-2025-24010) and GHSA-p9ff-h696-f583 (CVE-2026-39363)
- Vite docs: server options
- OWASP WebSocket Security Cheat Sheet
- Chrome: validate web origins
- MDN: Origin header
- InstaTunnel pricing
Related InstaTunnel pages
Continue from this article into the most relevant product guides and workflows.
Related Topics
Keep building with InstaTunnel
Read the docs for implementation details or compare plans before you ship.