Cross-origin unauthenticated WebSocket DoS: no Origin check + unhandled JSON.parse crashes the server
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- javascript
Research direction
Start in server.js at setupReloadNotifier around lines 1002-1003, then inspect the updateServer connection handler and its WebSocket handshake handling. Reproduce the malformed-frame case from the issue and trace the accepted Origin header. Done means untrusted origins are handled according to the project's local-origin policy and malformed messages no longer terminate the server.
Written by the indexing model from the issue text.
Description
Summary
The live-reload WebSocket server accepts connections from any origin (no Origin header validation during the handshake), and its message handler calls JSON.parse() on incoming frames with no try/catch. Any web page — including a malicious third-party site a developer merely has open in another browser tab while running eleventy --serve — can open a cross-origin WebSocket to the dev server and send one non-JSON frame to crash the entire process.
CWE: CWE-346 (Origin Validation Error) + CWE-248 (Uncaught Exception)
Severity: High
CVSS: 8.1 — CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:N/I:N/A:H
Root Cause
server.js (setupReloadNotifier's WebSocket connection handler), around line 1002-1003:
ws.on("message", (data) => {
let parsed = JSON.parse(data.toString()); // no try/catch
...
updateServer.on("connection", ...) never inspects the handshake Origin header before accepting the WebSocket connection, so the classic "malicious webpage attacks your localhost dev server" pattern (the same class of bug behind several historical webpack-dev-server DNS-rebinding/cross-origin advisories) applies here directly.
Reproduction
With the dev server running (see companion issue #150 for setup), from a separate script simulating a cross-origin page:
const ws = new WebSocket("ws://localhost:PORT", { headers: { Origin: "http://evil.example.com" } });
ws.on("open", () => ws.send("NOT-VALID-JSON{{{"));
Server log:
SyntaxError: Unexpected token 'N', "NOT-VALID-JSON{{{" is not valid JSON
at server.js:1003:27
Node.js v22.23.2 [process exits]
Verified: the connection was accepted despite the spoofed Origin header, and the server was confirmed alive before the frame and dead after.
Impact
Any web page a developer has open — completely unrelated to the site being built — can crash their local eleventy --serve session at will, with zero warning, just by the developer having that page open in another tab. This also means a malicious ad, compromised third-party script, or any attacker-controlled page can deny service to a developer's workflow.
Recommended Fix
- Validate the
Originheader during the WebSocket upgrade/handshake, accepting onlynull/expected local origins (or use theverifyClientoption most WS libraries provide). - Wrap
JSON.parse()in a try/catch and simply ignore/close the connection on malformed input instead of letting the exception propagate.
Verification
Dynamically confirmed on v3.0.0-alpha.11 against a real running server instance with a real cross-origin WebSocket client, as shown above.
- Dominant language
- JavaScript
- Stars
- 109
- Forks
- 19
- Avg merge
- 6d 3h
- Merged PRs (30d)
- 2
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from 11ty/dev-server
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
11ty/dev-server#95 ·
-
needs-votes
Difficulty 4/5 3-5 days Newbie friendliness 35/100
11ty/dev-server#113 · 2 comments ·
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 25/100
11ty/dev-server#86 · 1 comment ·
-
enhancement needs-votes
Difficulty 3/5 1-2 days Newbie friendliness 45/100
11ty/dev-server#82 · 4 comments ·
-
enhancement needs-votes
Difficulty 3/5 1-2 days Newbie friendliness 45/100
11ty/dev-server#53 · 3 comments · 2 reactions ·
Similar issues
-
[quality] useFocusTrap's Shift+Tab wrap and non-Tab/non-Escape key arms are never driven end to endPossibly taken @hivecommons-hive claimed this today. Openagent/quality hive/covered-by-pr hive/hosted-available-lke648397-260827-5n31 quality testing
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
agentic-workflows
Difficulty 1/5 Under an hour Newbie friendliness 85/100
githubnext/gh-aw-workshop#4220 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
JuliusBrussee/caveman#1189 ·
Maintainers usually reply within 1 day
-
priority:low ready-for-dev
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
OpenHands/extensions#738 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
invoiceninja/invoiceninja#13320 ·
Maintainers usually reply within 1 day