Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/Server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
"use strict";

function isTrustedClient(req) {
// Only allow injection if client explicitly identifies itself
return req.headers["webpack-dev-server-client"] === "true";
}

const os = require("os");
const path = require("path");
const url = require("url");
Expand Down Expand Up @@ -2103,6 +2108,13 @@ class Server {
/** @type {import("webpack-dev-middleware").API<Request, Response>}*/
(middleware).waitUntilValid((stats) => {
res.setHeader("Content-Type", "text/html");

if (!isTrustedClient(req)) {
res.statusCode = 403;
res.end("Access denied: Missing required dev server client header.");
return;
}

res.write(
'<!DOCTYPE html><html><head><meta charset="utf-8"/></head><body>'
);
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webpack-dev-server",
"version": "4.15.2",
"name": "webpack-dev-server-wajih",
"version": "4.6.0-patched",
"description": "Serves a webpack app. Updates the browser on changes.",
"bin": "bin/webpack-dev-server.js",
"main": "lib/Server.js",
Expand Down